Theme selector block

Introduction

Have you ever wanted to compare themes easily? In “What’s in a screenshot” (March 2018), I briefly mentioned my ‘Theme selector’ block that I took over from John Syrinek. It gives you the ability to switch between themes quickly so that you can make the comparisons you want.

Disclaimers and license

Firefox® is a registered trademark of the Mozilla Foundation – www.mozilla.org/en-US/foundation/trademarks/policy/.

Ubuntu® is a registered trademark of Canonical Ltd – ubuntu.com/legal/intellectual-property-policy.

Moodle™ is a registered trademark of ‘Martin Dougiamas’ – moodle.com/trademarks.

Other names / logos can be trademarks of their respective owners. Please review their website for details.

I am independent from the organisations listed above and am in no way writing for or endorsed by them.

The information presented in this article is written according to my own understanding, there could be technical inaccuracies, so please do undertake your own research.

References

Installing

As an administrator, you install the block like any other plugin using the method of your choice, docs.moodle.org/en/Installing_plugins, with reference to moodle.org/plugins/block_theme_selector:

Installing the 'Theme selector' block.

You’ll then get the option of excluding themes and making aliases for them:

Theme selector block new settings.

Along with the ‘URL switching’, which I’ll describe in a moment, and the ‘Window information’ that I wrote about in ‘What’s in a Screen shot?’.

The best place to put the block is on the home page as that’s the top level, and then make it available on all pages, so after adding the block and selecting the ‘Configure Theme selector block’ from the block editing cog (just like any other block):

Configuring the Theme selector block.

We set the block to appear throughout the entire site. After saving changes, you’ll notice that there is a message (if you’ve kept the default setting value for ‘theme_selector_url_switch’):

'allowthemechangeonurl' setting warning.

This is the fastest means of switching theme and also does not change the theme set in the core ‘Theme selector’ (docs.moodle.org/en/Standard_themes#Theme_selector). Search for ‘allowthemechangeonurl’ (which is a core setting) and set it:

Administration search for 'allowthemechangeonurl' core setting.

Which you can see under ‘Theme settings’ in the screen shot. And that’s it for installation.

Use

Using it is now really easy, simply select the theme you want using the drop down menu:

Theme selection.

And the code will detect the change in the selected theme and refresh the page.

You’ll also see a button ‘Reset theme cache’ (along with ‘Window information’ if you’ve enabled ‘block_theme_selector_window’), that is a quick way of resetting the theme cache:

Extra theme selector functions.

These options are to help theme developers and documentation writers with their work.

Conclusion

I believe that the block is a really useful tool, which is why I maintain it. What do you think please?

Gareth Barnard
Latest posts by Gareth Barnard (see all)
blank

Gareth Barnard

Gareth is a developer of numerous Moodle Themes including Essential (the most popular Moodle Theme ever), Shoelace, and other modules such as course formats.

One thought on “Theme selector block

  • 16th June 2021 at 2:19 pm
    Permalink

    Such a useful Block !
    I think many organisations could use this, to allow users to change to a Theme that suits them – instead of everyone using the Theme that the marketing department or the Moodle admin thinks is best 😉

    Reply

Add a reply or comment...

%d bloggers like this: