Issues Creating new theme

Issues Creating new theme

by Jamie Tinley -
Number of replies: 14

Mary Evans, Emma Richardson, Rick Jerz please et al.  help!  

I thought creating 6 variations of a theme would be a simple learning curve - wrong!  I just want the boost_learning theme in 6 different colors for each department.  I have been reading each of your posts for a few weeks and watching Rick Jerz videos on creating a theme based on boost and documentation here.    I tried both stageone and stagetwo examples but they would never upload to Moodle plugins so I finally made a 6 copies of boost_training and used notepad plus to search every single file and replace all instances of the word boost_training with Boost_green, ect for pink, yellow, blue, purple, yellow for each theme.  I also had to change 3 document names in in three places in the paths theme/Lang/en   theme/lang/pt_br  and theme/scss.

They uploaded fine into moodle but they all had the same theme name despite changing it everywhere. (said boost_training).  Looking at the list of plugins they each had the correct theme name as a subname.  I triple checked that I did not miss anywhere and I didn't. 

The error it shows when choosing the theme is 

Exception - Call to undefined method core_renderer on lines, line 42  layout/columns2.php, 1261  lib/outputrenderers.php, 1191 lib outputrenderers

I checked out those errors and found two links solving it here and here but there example differs from mine - I find the word core_renderer in 4 places but none of them are like their example which should be like this: class theme_mytheme_core_renderer extends theme_boost\output\core_renderer

I tried to change it anyway and did it like below in these two paths: classes/output/core_renderer.php on line35 and in same path core_renderer_maintenance.php on line 37 

class theme_boost_green_core_renderer extends \theme_boost\output\core_renderer

class theme_boost_green_core_renderer_maintenance extends \theme_boost\output\core_renderer_maintenance

The error remains sad  I am at a loss with something I thought would be easy to just have 6 different colored themes for each department for the theme boost_training.  

aside: I also compared to boost_learning which is a child of theirs by Kraus which did not change lines 35 and 37 so I'm guessing it's something I need to register at git or somewhere maybe.  Boost_learning is ok but is missing the the icon for the 2nd navbar button and that would only make 1 extra theme not 6 If I could make it work.  In that issue using the inspector in firefox I noticed the issue to be fixed is  <div class="btn pull-xs-left btn-secondary navbar-toggler" aria-expanded="true" aria-controls="nav-drawer" data-action="toggle-drawer" data-side="left" data-preference="drawer-open-nav"

In the hopes to have at least 2 of the same theme I tried to copy the working example from boost_training to it without success.  So any ideas to help me is greatly appreciated.

Average of ratings: -
In reply to Jamie Tinley

Re: Issues Creating new theme

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

Are your departments organised into categories on your moodle site?

If so, then much easier, if all you are trying to do is change a few colours, then use a single theme and apply the colours using the category id from the body classes.

Re theme name changes though - the displayed theme name you are seeing will be from the language file and needs changing - because its the displayed name it may be different, so if you are using a search and replace tool it may not find it (eg space instead of underscore, capitalised, etc)

If you are using Boost upto Moodle3.4, try the Photo theme and its tutorial, or my Waxed theme (built from that) and clone those - they are children of Boost and I have cloned/renamed Waxed many times and it just works as expected. Note it will NOT work yet on the new Boost for 3.5 because of the changes to Bootstrap4Stable.

Not sure which stageone/stagetwo themes you are referring to, but if they were the ones I created, then they were in the very early days of Boost and have not been updated since so may not be working on newer version, and were simply stages in following the Photo tutorial - which has been updated, so much better to follow that.

Richard

In reply to Richard Oelmann

Re: Issues Creating new theme

by Jamie Tinley -
Thanks for replying Richard!  

Yes, I was using your link here for doing stageone and stagetwo.  I think I got you and Rick Jerz conflated.  I tried Waxed and like it too but I really liked the icons in the left sidebar of boost-training if I can make 6 themes of it.  I do generally use categories for each department but there are teachers who sometimes want to use a different theme within that category and be different.  I also have a catchall category (misc courses) where the teachers all use different themes.  I will search again for caps but I thought I said ignore it and I did look for spaces.  I will try photo.  Is that tutorial the one here?  That has the same bit.ly link for stageone and stagetwo here so maybe not.  Looking forward to learning more from you thanks!

In reply to Richard Oelmann

Re: Issues Creating new theme

by Jamie Tinley -

HI Richard, this is a side question but why does the Waxed theme and Handlebar themes both ask you to save settings and in a sense 'hang' there even if you click save when you go to a url like this: http://yoursiteurl/moodle/admin/upgradesettings.php

In reply to Jamie Tinley

Re: Issues Creating new theme

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

Hi Jamie,

I was just reading all your comments here and thought I might ask if you had Theme Designer Mode "ON" as this can slow you down and drive you to distraction as you tap your fingers on the table telling Moodle to "getta move on!"

Been there, done that...

Cheers

Mary

In reply to Mary Evans

Re: Issues Creating new theme

by Jamie Tinley -

Thanks Mary, good insight!  So will 6 duplicates of that theme but all renamed cause me any issues down the line?  I realize if I update the main theme I may need to repeat this process as It might not update automatically on it's own. any other dangers? Thanks again, Jamie

In reply to Jamie Tinley

Re: Issues Creating new theme

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

Hi Jamie,

There is nothing stopping you making your main theme the parent and your course themes child themes!

This way the child themes would inherit the parent's changes, thus saving you loads of time and stress.

Hope this helps?

M

In reply to Mary Evans

Re: Issues Creating new theme

by Jamie Tinley -

Sorry to ask you one more thing Mary but how do I make them all child theme's of the main boost_training theme?

In reply to Jamie Tinley

Re: Issues Creating new theme

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

What is on line 42 of layout/columns2.php?

What version of Moodle please?

In reply to Gareth J Barnard

Re: Issues Creating new theme

by Jamie Tinley -

Hi Gareth!  I've used your themes in the past thanks for replying!

I just upgraded to Moodle 3.4 on ubuntu with apache 2.4 and php 7.2!  

Line 42 of column2.php says:

$regionmainsettingsmenu = $OUTPUT->region_main_settings_menu();

which did not mean a lot to me.

Thanks for any insight you have - Jamie

In reply to Jamie Tinley

Re: Issues Creating new theme

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

Ah ok...

So the $OUTPUT is a global variable containing an instance of the class 'core_renderer'.  This is sub-classed by 'Boost' from the parent in 'lib' and adds the method 'region_main_settings_menu' - I think.  So if this is failing then your overridden sub-class is not working.  This can be difficult in Moodle and is called 'Automatic class loading' - https://docs.moodle.org/dev/Automatic_class_loading. So given what you have described, then I think you need in your 'classes/output/core_renderer.php' file (and similar with the maintenance one) is:

namespace theme_boost_green\output;
class core_renderer extends \theme_boost\output\core_renderer {

This may then throw up other issues with namespaces so either prefix with a backslash, e.g. '\html_writer::start_div(' etc. or add 'use html_writer;' at the top of the file after the 'namespace'.

G


In reply to Gareth J Barnard

Re: Issues Creating new theme

by Jamie Tinley -

HI Gareth, thanks - I looked in my core_renderer.php and I see mine is the same as you suggest exactly.  

namespace theme_boost_green\output;

class core_renderer extends \theme_boost\output\core_renderer {

and reading your link on classes was a little above my head. re-read it and yours but it's not sinking in yet.


In reply to Jamie Tinley

Re: Issues Creating new theme

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

Hi Jamie,

Sorry I have only just got to read your request for help!

Naming themes is a pain and Boost is a pain too as I have just spent hours trying to code it via the settings page and having a terrible time!

As for your themes having the same name in the title, then you have not changed your themes lang/en/theme_themename.php (where themename is the name of your theme.)

See Boost theme as an example:

https://github.com/moodle/moodle/blob/MOODLE_34_STABLE/theme/boost/lang/en/theme_boost.php#L36

To be honest we would need to see at least one of your themes to understand what problems you are having.

Also, you really need to understand that it's easier to make a minimalist child theme to work how you want it to, and as such would only need to contain the necessary changes be it colour or images oor specific code changes (templates), as all the rest of the theme would be coming direct from Boost itself as  the parent theme!

Cheers

Mary

In reply to Mary Evans

Re: Issues Creating new theme

by Jamie Tinley -

Thanks Mary! I found what you suggested and you were correct - I had changed the outside file name of theme_boost_green but inside for some reason my global search using notepad++ failed to find 3 changes there for Training. Maybe it was since it was a capital T in this case I'm not sure. 


I would LOVE to just use the child themes in different colors but so far I have not been successful making child themes using Richard Oelmann nor Rick Jerz tutorials. I'm thinking I'm using Richard's old tutorial but I also tried following the moodle one here.  Thanks for helping. I'll try to zip with changes and get back to you all.

In reply to Mary Evans

Re: Issues Creating new theme

by Jamie Tinley -

Cool Mary, changing the name worked!  It also solved the core_renderer error so now I have a green boost training theme. Now to copy it 5x for all the other themes.  Hopefully doing it this way is ok and won't crash my courses later on. Emma had raised concern that Kraus's themes were at one time only for Moodle versions 3.2 not above but currently his themes say up to 3.4 so I'm hoping have 6 copies with different names will not cause issues.

Thanks again for everyone's help and input. - Jamie