Can someone please explain why...

Can someone please explain why...

by Mary Evans -
Number of replies: 4
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

...the Essential theme has a setting that uses CDN FontAwesome when FontAwesome is already in the Essential theme fonts folder?

/**
* Include the Awesome Font.
*/
function theme_essential_set_fontwww($css) {
    global $CFG, $PAGE;
    if(empty($CFG->themewww)){
        $themewww = $CFG->wwwroot."/theme";
    } else {
        $themewww = $CFG->themewww;
    }
    $tag = 'setting:fontwww';
    
    $theme = theme_config::load('essential');
    if (!empty($theme->settings->bootstrapcdn)) {
            $css = str_replace($tag, '//netdna.bootstrapcdn.com/font-awesome/4.0.0/fonts/', $css);
    } else {
            $css = str_replace($tag, $themewww.'/essential/fonts/', $css);
    }
    return $css;
}
Thanks Mary
Average of ratings: -
In reply to Mary Evans

Re: Can someone please explain why...

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Perhaps at a guess because the CSS is not using the font:theme syntax which refers to the fonts folder but rather 'setting:fontwww' is there instead.  I suspect as a hang over from before the font:theme functionality was implemented by Petr Skodak I believe.

And has a CDN setting that allows users to use CDN / local fonts as their situation demands.  CDN having certain advantages over local files in some situations.

In reply to Gareth J Barnard

Re: Can someone please explain why...

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

What advantages do they have that makes it necessary to build this functionality into a theme?

Let's fact it I doubt if Moodle HQ would allow this in a CORE theme, or would they?

In reply to Mary Evans

Re: Can someone please explain why...

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Oh ok...

Well, firstly if I could predict how Moodle HQ thought, then I would not be here as I would be able to pick the correct lottery numbers and be on a beach somewhere relaxing, although admittedly still coding.

As for not using 'font:theme' for the local version I don't really know bar perhaps time to upgrade to it.

For CDN, they have the advantage of reducing bandwidth on your site and hence hosting cost and if another site uses the same CDN and font then the URL will already be in the users cache.  So a HTTP 304 will happen and the local cached copy from the CDN will be used.  Hence faster page loading times.  However with CDN, you do need internet access with no filtering on the CDN provider, so is not practical for situations where Moodle is hosted and accessed on an intranet, the local solution is the only viable one.

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

Re: Can someone please explain why...

by Julian Ridden -

Just confirming what has been said is 100% correct.

This was written before the font:theme syntax was created, and as this method still works I have not seen an urgent need to update it with the new setting.

Why CDN? Well basically what Gareth said. Less bandwidth and offer better performance. For those that are looking for every single little advantage they can get, CDN is often a great solution.

Why a setting? Well, not everyone has Moodle loading in a web accessible environment. Or strict firewall rules may block CDN access. For this reason it is a setting (off by default) that admins who want to ca enable if it is there want.

If anyone wants to send a patch I am happy to include it. Otherwise it is just one of those things Ill get round to doing in time. My current focus is bug squashing and a couple of new requested features.

Julian

Average of ratings: Useful (2)