diff --git a/classes/layout/accordion.php b/classes/layout/accordion.php index a08591f..e520266 100644 --- a/classes/layout/accordion.php +++ b/classes/layout/accordion.php @@ -50,10 +50,16 @@ public function get_suggested_use() : string { * @return string The Mustache template. */ public function get_template() : string { - if (!helper::is_totara()) { - return 'block_multiblock/accordion-bootstrap4'; - } else { + global $CFG; + // Totara uses Bootstrap 3. + if (helper::is_totara()) { return 'block_multiblock/accordion-bootstrap3'; } + // Starting with Moodle 5.0, Moodle uses Bootstrap 5. + if ($CFG->version >= 2025041400) { + return 'block_multiblock/accordion-bootstrap5'; + } + // For Moodle versions before 5.0, use Bootstrap 4. + return 'block_multiblock/accordion-bootstrap4'; } } diff --git a/classes/layout/tabbed_list.php b/classes/layout/tabbed_list.php index c7fae26..047ba10 100644 --- a/classes/layout/tabbed_list.php +++ b/classes/layout/tabbed_list.php @@ -61,10 +61,16 @@ public function get_layout_id() : string { * @return string The Mustache template. */ public function get_template() : string { - if (!helper::is_totara()) { - return 'block_multiblock/tabbed-list-bootstrap4'; - } else { + global $CFG; + // Totara uses Bootstrap 3. + if (helper::is_totara()) { return 'block_multiblock/tabbed-list-bootstrap3'; } + // Starting with Moodle 5.0, Moodle uses Bootstrap 5. + if ($CFG->version >= 2025041400) { + return 'block_multiblock/tabbed-list-bootstrap5'; + } + // For Moodle versions before 5.0, use Bootstrap 4. + return 'block_multiblock/tabbed-list-bootstrap4'; } } diff --git a/templates/accordion-bootstrap5.mustache b/templates/accordion-bootstrap5.mustache new file mode 100644 index 0000000..905fea6 --- /dev/null +++ b/templates/accordion-bootstrap5.mustache @@ -0,0 +1,60 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template block_multiblock/accordion-bootstrap4 + + This template shows the multiple blocks in an accordion + + Example context (json): + { + "multiblockid": 28, + "multiblock": [ + { + "id": 1, + "title": "Block 1", + "content": "

Block 1

", + "footer": "My footer", + "active": true + }, + { + "id": 2, + "title": "Block 2", + "content": "

Block 2

", + "footer": "", + "active": false + } + ] + } +}} +
+ {{#multiblock}} +
+

+ +

+
+
+ {{{content}}} + + {{{annotation}}} +
+
+
+ {{/multiblock}} +
diff --git a/templates/tabbed-list-bootstrap5.mustache b/templates/tabbed-list-bootstrap5.mustache new file mode 100644 index 0000000..0967439 --- /dev/null +++ b/templates/tabbed-list-bootstrap5.mustache @@ -0,0 +1,62 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template block_multiblock/tabbed-list + + This template shows the multiple blocks in a tabbed view + + Example context (json): + { + "multiblockid": 28, + "multiblock": [ + { + "id": 1, + "title": "Block 1", + "content": "

Block 1

", + "footer": "My footer", + "active": true + }, + { + "id": 2, + "title": "Block 2", + "content": "

Block 2

", + "footer": "", + "active": false + } + ] + } +}} +
+ +
+ {{#multiblock}} +
+
+ {{{content}}} + + {{{annotation}}} +
+
+ {{/multiblock}} +
+
\ No newline at end of file