1. Config.php
Update $THEME->layout
In config frontpage is already available so we only need to add ‘full-width-top region on existing one
We had to add mydashboard layout which is copied by boost theme because Almondb is child theme of boost theme and than after we add added ‘full-width-top to existing region
Code:
$THEME->layouts = [
// The site home page.
‘frontpage’ => [
‘file’ => ‘frontpage.php’,
‘regions’ => [‘side-pre’, ‘full-width-top’],
‘defaultregion’ => ‘side-pre’,
‘options’ => [‘nonavbar’ => true],
],
‘mydashboard’ => array(
‘file’ => ‘drawers.php’,
‘regions’ => array(‘side-pre’, ‘full-width-top’),
‘defaultregion’ => ‘side-pre’,
‘options’ => array(‘nonavbar’ => true, ‘langmenu’ => true),
),
];
See the below screenshot
2. Changing the relevant php file
Php file name is mentioned on config layout with file field (see the $THEME->layout layouts)
For frontpage – frontpage.php
And for mydashboard – drawers.php is mention
-> these files are located on layout folder of theme and if not present directly copy it by boost layout and paste it to Almondb theme layout folder to make some changes
For frontpage.php and drawers.php is already present on Almondb theme
1. Changes on fronpage.php
Path: theme/almondb/layout/frontpage.php
At the bottom before this line echo $OUTPUT->render_from_template….);
Add these codes
Code:
if (in_array(“full-width-top”, $this->page->blocks->get_regions())) {
$addblockbuttonfwtop = $OUTPUT->addblockbutton(‘full-width-top’);
$sidefwtopblocks = $OUTPUT->blocks(‘full-width-top’);
// Strlen Calculation is total jugad.
if (trim($addblockbuttonfwtop) != ” || (trim($sidefwtopblocks) != ” && strlen($sidefwtopblocks) > 117)) {
$templatecontext[‘addblockbuttonfwtop’] = $addblockbuttonfwtop;
$templatecontext[‘sidefwtopblocks’] = $sidefwtopblocks;
$templatecontext[‘canaddfwtopblocks’] = true;
}
}
See the screenshot below
2. Same changes on drawers.php file
Path: theme/almondb/layout/drawers.php
3. Now we can add regions anywhere on frontpage, and dashboard by mustache file
1. For frontpage
You can add regions anywhere on the Frontpage or Dashboard via the related Mustache file.
The Mustache file path is mentioned in the last line of the related PHP file.
Example:
On the Frontpage, you will see this line at the end of the PHP file:
echo $OUTPUT->render_from_template(‘theme_almondb/frontpage/frontpage’, $templatecontext);
This means the Mustache path is:
frontpage/frontpage
It is located at:
theme/almondb/templates/frontpage/frontpage.mustache
Note:
To display the custom region at the top, add the output code after the header and before the frontpage_1 section.
Code:
{{#canaddfwtopblocks}}
<section id=”region-fullwidthtop-blocks” class=”has-blocks” aria-label=”region top blocks”>
<div role=”region-main”>
{{{ sidefwtopblocks }}}
{{#addblockbuttonfwtop}}
<div id=”region-fullwidthtop-blocks-indicator” class=”container-fluid block-indicator”>
<font class=”text-center p-px-2d5 m-0 bg-white block-indicator-text-wrapper “>
Full with top
</font>
</div>
{{/addblockbuttonfwtop}}
</div>
</section>
{{/canaddfwtopblocks}}
See the screenshot below
2. For dashboard layout
The same applies to the Dashboard layout.
The Mustache path used is:
theme_boost/drawers
Full location: theme/almondb/templates/theme_boost/drawers.mustache
Placement Instruction
Add the region display code just inside the page container,
right after this line: <div id=”page” data-region=”mainpage” data-usertour=”scroller” class=”drawers…..
Code:
{{#canaddfwtopblocks}}
<section id=”region-fullwidthtop-blocks” class=”has-blocks” aria-label=”region top blocks”>
<div role=”region-main”>
{{{ sidefwtopblocks }}}
{{#addblockbuttonfwtop}}
<div id=”region-fullwidthtop-blocks-indicator” class=”container-fluid block-indicator”>
<font class=”text-center p-px-2d5 m-0 bg-white block-indicator-text-wrapper “>
Full with top
</font>
</div>
{{/addblockbuttonfwtop}}
</div>
</section>
{{/canaddfwtopblocks}}
See the screenshot below
Now Enable the edit mode and go to the homepage, dashboard, or any custom page; you will now be able to add page builder blocks as well as Moodle blocks.