wwwroot is not working into header.mustache file Boost theme 3.4

wwwroot is not working into header.mustache file Boost theme 3.4

by Mark Brand -
Number of replies: 5

Hello Friends,

I am using moodle 3.4 boost theme.

I want using logo into other place of header when i place this ( <div class="pull-xs-left"><div class="logo"><img src="<?php echo $CFG->wwwroot;?>/theme/boost/pix/logo.png"></div></div> ) code into header.mustache file "<?php echo $CFG->wwwroot;?>" instead of http://www.mysite.com it is not working.

Please help me.


Thank You,

Advance



Average of ratings: -
In reply to Mark Brand

Re: wwwroot is not working into header.mustache file Boost theme 3.4

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

You have to first send the image URL to the mustache template.  To do this you will need to look at the layout file and add the image there first.  Then you can add it to the mustache template file.  

See this:  https://docs.moodle.org/dev/Using_images_in_a_theme#Using_your_images_within_your_layout_files

Mustache templates will not allow any PHP code.  

Once you add the line of code telling Moodle where the image is in the Layout file you simply add something like {{{ logoimage }}} (whatever you named it in the previous step) to the Mustache file and the image will appear.  

Hope that helps.

Chris

Average of ratings: Useful (3)
In reply to Chris Kenniburg

Re: wwwroot is not working into header.mustache file Boost theme 3.4

by Mark Brand -

Thank you so much chris. Really very helpful. Yes

In reply to Chris Kenniburg

Re: wwwroot is not working into header.mustache file Boost theme 3.4

by Mark Brand -

Hello Chris,

I have a query regarding using logo settings code.

In clean theme layout we are using php code like below,

if (!empty($PAGE->theme->settings->logo)) {

  $logourl = $PAGE->theme->setting_file_url('logo', 'logo');

}else{

  $logourl =$OUTPUT->image_url('/logo', 'theme');

}


Into boost theme i am using code like below

$templatecontext = [

'logourl' => $PAGE->theme->setting_file_url('logo', 'logo'),$OUTPUT->image_url('/logo', 'theme'),

];

But it is not working. 

Actually i want a default logo and change logo after uploading.


Thank You

Advance.

In reply to Mark Brand

Re: wwwroot is not working into header.mustache file Boost theme 3.4

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
if (!empty($PAGE->theme->settings->logo)) {
  $logourl = $PAGE->theme->setting_file_url('logo', 'logo');
} else {
  $logourl = $OUTPUT->image_url('/logo', 'theme');
}
$templatecontext = [
'logourl' => $logourl
];

or if the $templatecontext code is in the core_renderer.php file then:

if (!empty($this->page->theme->settings->logo)) {
  $logourl = $this->page->theme->setting_file_url('logo', 'logo');
} else {
  $logourl = $this->image_url('/logo', 'theme');
}
$templatecontext = [
'logourl' => $logourl
];

Suggestion: https://www.w3schools.com/php/default.asp.

Average of ratings: Useful (1)
In reply to Gareth J Barnard

Re: wwwroot is not working into header.mustache file Boost theme 3.4

by Mark Brand -

Thank you so much Gareth. smile Very useful.