Last active
March 15, 2022 03:35
-
-
Save frumbert/221536dac8f65a5f853b939873dbba24 to your computer and use it in GitHub Desktop.
Sample theme template renderer for filter_units (https://github.com/frumbert/filter_units)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{>theme_mytheme/inc_start}} | |
<div id="page" class="container-fluid"> | |
{{{ output.full_header }}} | |
<div id="page-content" class="row"> | |
<div id="region-main-box" class="col-12"> | |
{{#hasregionmainsettingsmenu}} | |
<div id="region-main-settings-menu" class="d-print-none"> | |
<div> {{{ output.region_main_settings_menu }}} </div> | |
</div> | |
{{/hasregionmainsettingsmenu}} | |
<section id="region-main"> | |
<div class="card"> | |
<div class="card-body"> | |
{{#hasregionmainsettingsmenu}} | |
<div class="region_main_settings_menu_proxy"></div> | |
{{/hasregionmainsettingsmenu}} | |
{{#coursehome}} | |
{{> core/single_button }} | |
{{/coursehome}} | |
{{{ output.course_content_header }}} | |
{{{ output.main_content }}} | |
{{{ output.course_content_footer }}} | |
</div> | |
</div> | |
{{{ output.activity_navigation }}} | |
</section> | |
</div> | |
</div> | |
</div> | |
{{>theme_mytheme/inc_end}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$templatecontext = [ | |
'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]), | |
'output' => $OUTPUT, | |
'sidepreblocks' => $blockshtml, | |
... | |
'coursehome' => theme_mytheme_coursehome_button($OUTPUT) | |
]; | |
echo $OUTPUT->render_from_template('theme_mytheme/columns2', $templatecontext); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function theme_mytheme_coursehome_button($output, $consume = true) { | |
global $SESSION; | |
if (isset($SESSION->coursehome)) { | |
$coursehomeurl = new \moodle_url($SESSION->coursehome); | |
if ($consume) unset($SESSION->coursehome); | |
$url = new \single_button($coursehomeurl, get_string('returntocourse', 'filter_units'), 'get', true); | |
$data =$url->export_for_template($output); | |
return $data; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment