Running two or more instances of the same theme

Running two or more instances of the same theme

by Kristina Schneider -
Number of replies: 5
I was wondering what is the safe way of running two or more instances of the same theme. Essentially, we would like to run the same theme throughout our site, but would like to have different instances of it with different colour schemes and logos for different course categories. 


We have the "force category theme option on, but we only seem to be able to have one instance of each theme. Would anyone know a safe workaround? FYI, we're running Moodle2.8.5+ (Build: 20150421) 


Thanks in advance! 

K.

Average of ratings: -
In reply to Kristina Schneider

Re: Running two or more instances of the same theme

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers
Create child themes which are very simple, applying just the css and images you want for each instance. That will allow any development changes made to the original theme to be inherited rather than havign to make the same changes to mutliple themes.

Your themes would need a config.php and list the original theme in as one of its parents, the version.php should add the original theme as a dependency and your style folder and pix folder would hold the changes to the colour scheme/logo etc.

The alternative is to use the category id, which should be found as a body class as an identifier for your targetted css. That way you just have the one theme, but your css can be specificied to certain categories.
In reply to Richard Oelmann

Re: Running two or more instances of the same theme

by Kristina Schneider -

Hi Richard,

Thanks for your reply. Do you know of a good tutorial on how to create a child theme in Moodle? I've found a few tutorials online, but I'm always a little weary. This one seems to be referenced a few times, but then the author says he's not a fan of Moodle: http://peter.upfold.org.uk/blog/2013/11/30/creating-a-custom-child-theme-in-moodle-2-6/ so I'm taking him with a grain of salt. Since you seem to know what your doing, can you confirm is this is the way to do it?


Kristina

In reply to Kristina Schneider

Re: Running two or more instances of the same theme

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Well, that video isn't quite accurate - Partly because some things have changed since 2.6 (needs a version.php) and some of it just isn't needed - you can lose a lot more out of the config.php, including the names of all the style sheets other than the one you need in your own child theme and you can also lose all the layout file array from there unless you are changing the layout files in your child theme (which if all you are changing is logos and colour schemes as per your original post, you don't need)

Although Peter says in that blog post 'I think it's actually an easier process than people think!' I actually think its even easier than he suggests smile


I've attached a very simple child theme for Clean, which should work. Of course, if you want to start adding changes to layout files, or adding your own theme settings page thats when things start to get a bit more complicated, but as a simple, 'change a few colours and logo' child theme, this should be a starting point.

You can add any css you want to the cleanchild.css file in the style folder - I've added a pix folder, which isn't strictly necessary in a child theme, but as you said you were looking at changing logos, then that would be the place to store them and reference them from your css as per https://docs.moodle.org/dev/Using_images_in_a_theme

Hope that helps

PS: the blue body background added in cleanchild.css is just to show its working and should be changed asap :D

In reply to Richard Oelmann

Re: Running two or more instances of the same theme

by Kristina Schneider -

Hi Richard,


I mean to write back earlier to say thanks. I had to shelve this project for a while, but I'm back at it now. I ended up just completely duplicating the clean theme instead of using a child theme, as after hours of trying, I couldn't get a logo to show up. All seems to be working well. 


Thanks again for the help!

K.