Totara Learn Open Discussions

Theme Question - Mustache / Logo Image

 
John Unnever
Theme Question - Mustache / Logo Image
על ידי John Unnever בתאריך 22/07/2021, 06:09
קבוצה Partners

Hello!

We have modified our email template in: theme/((themename))/templates/core/email_html.mustache  to include the site logo image.

Using syntax:    {{#pix}}logo{{/pix}}


The image shows up in our emails when the logo.png is found in this directory:

/sitedata/localcache/theme/(random number here)/(themename)/pix/core


Question:  In one of our environments, it's working.. because the image is in this directory.  In other environments, no matter how many times i've deleted, re-uploaded a new site logo, purge caches, etc..  the site logo   logo.png  is not ending up in that location, so our mustache template is not able to find it and include it in the email.    Is there a different syntax we should be using to bring the logo into our template?  Different naming of the site logo file?   Should the site logo uploaded via the theme settings be placing the file into that localcache  ..../pix/core directory when it's applied?   Since it works when we see the logo.png file there, i gotta imagine that's where it needs to be..  anywho, any help would be appreciated!  

John Unnever
Re: Theme Question - Mustache / Logo Image
על ידי John Unnever בתאריך 26/07/2021, 07:06
קבוצה Partners

Update:  So i have successfully gotten the logo.png to populate into that localcache/theme/xxx/themename/pix/core  directory...   By placing the logo.png inside the theme plugin directory   /html/theme/themename/pix_core     


The problem with this is that we have multiple customers so they have different logos.. we would need to create a theme per customer .. (unless there is a logic based way of choosing which theme .. but as i understand mustache .. it's meant to be logic-less)

What i was hoping for was to pull from whatever image was uploaded for use as the site logo via the UI .. 

Is it possible ?     rather than  {{#pix}}logo{{/pix}}   is there some other syntax like  {{#pix}}site_logo{{/pix}}  ?  I'm just really not very familiar with mustache templates or how it's been baked in to know for sure.


Thank you!

Brian Barnes (Core Developer)
Re: Theme Question - Mustache / Logo Image
על ידי Brian Barnes (Core Developer) בתאריך 26/07/2021, 13:48
קבוצה Totara

Hi John,

When using the `#pix` helper to get the logo, yes it will rely on the image as provided in the theme. This improves caching of icons (eg. up and down arrows etc.) and is widely used throughout the site.

After uploading a logo through Ventura or Basis theme settings (I'm assuming you're trying on t12 or above here), the URL for the logo can be retrieved using `logourl` in `totara_core\masthead_logo` template, or by providing`$PAGE->theme->setting_file_url('logo', 'logo');` to your mustache template. For an example (including fallback code in the case where the setting is not set), have a look at the `export_for_template` method in `server/totara/core/classes/output/masthead_logo.php` (TXP13+).

PS. Don't forget the alt text so that a screen reader user knows what the logo is (`logoalt` in the masthead template or `$PAGE->theme->settings->alttext` from PHP).

Kind regards