HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by Paul Nicholls -
Number of replies: 12

As a few people have asked about using the Awesomebar in their own themes, I've created a basic example of a theme which inherits from Decaf - and therefore has not only the Awesomebar but also the edit buttons and other Decaf features.  The main benefits of inheriting from Decaf rather than cloning it are that it results in a leaner, simpler theme and that you don't have to manually merge in any future changes to Decaf - just update your copy of Decaf.

To go along with Decaf Green (the sample theme), I've written some instructions on how to turn it into your own custom theme which inherits from Decaf.  These instructions can be found on the Decaf Green Github wiki - if you have a go at it and have any feedback, please let me know; a private message either here or on Github is best if it requires action or a response, but please feel free to post feedback here too.

(Edited by Miriam Laidlaw - original submission Tuesday, July 24, 2012, 10:24 AM - edited link as per request)

Average of ratings: Useful (3)
In reply to Paul Nicholls

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

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

Thanks for this Paul...I've forked it to my GitHub smile

But not had time to play with it yet!

In reply to Paul Nicholls

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by skylyn mcferson -

Thanks paul. Maybe this would be considered an unrelated question, but how can I get the awesomebar to show the course sections/activities in the menu bar on the frontpage? Right now, the menu bar only shows the user's courses on the frontpage (in the menu bar), then when they go into the course, the meu bar will display the sections/activities for that course. 

In reply to Paul Nicholls

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by Sam Thing -

Hi Paul,

This all seems to be tickety boo as far as functionality goes but my theme is now called pluginname on all site admin pages so I'm missing something. Can you advise please?


Thanks, Sam.

In reply to Sam Thing

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by Paul Nicholls -

Hi Sam,

It sounds as though either your language file is misnamed or missing, or the 'pluginname' string is missing.  Double-check that your language file is sitting in /theme/yourthemename/lang/en/theme_yourthemename.php, and that it contains the following line:
$string['pluginname'] = 'Your Theme Name';

Make sure that the "yourthemename" part of the file name matches the "yourthemename" folder (i.e. if the theme folder is called sams_great_theme, the file should be called theme_sams_great_theme.php).

If the file is definitely called the right thing, and it definitely contains a valid entry for 'pluginname', it could be that the strings (or lack thereof) have been cached - you can try clearing all Moodle caches from Site Administration -> Development -> Purge all caches.  You might also want to enable Theme Designer Mode (Site Administration -> Appearance -> Themes -> Theme settings) while you're working on your theme, to avoid other issues with caching.

HTH,
Paul

Average of ratings: Useful (2)
In reply to Paul Nicholls

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by Sam Thing -

Thank you,

I'd missed theme_ off my theme name in the lang folder. It's all in order now and my theme is about ready for live consumption.

Brilliant HOWTO; or should I say awesome.

Thanks again,

Sam.

In reply to Sam Thing

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by Sam Thing -

Bad news:

With the bar in my theme our live moodle runs like a dog with 6 to 12 second page load times. Obviously this is unacceptable.

I've done the usual - turn off theme designer mode - optimise caching - but reading around the forum there seems to be a split between people who have a performance hit from using Decaf and those that don't, with nothing obvious to point at causing the hit sad

It's too near to the new academic year now to do anything about it so I'm putting this to bed for 9 or 10 months while we work on optimising the hardware and software environment of our moodle server for performance smile

Not to take away from your howto mind - worked like a charm.

Sam.

In reply to Sam Thing

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

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

Just a note to say...be careful when enabeling CSS Optimiser as it can break some Moodle Themes.

In reply to Sam Thing

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by Alek Hartzog -

Decaf broke us at some point too sad.

In reply to Sam Thing

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by Paul Nicholls -

Hi Sam,

As you say, there doesn't seem to be anything obvious separating those who see a performance hit from those who don't - but the one thing that usually seems to help for those who do see the hit is removing the navigation block (not just hiding it using the Decaf theme settings, but actually deleting the block instance - or changing it to front page only, invisible on front page).  I'm not really sure why, since it doesn't seem to make much difference to DB queries or memory usage, but it's something that's still on my list of things to investigate further when I find the time.

-Paul

In reply to Paul Nicholls

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by Paul Nicholls -

Just a quick update - I've changed my Github username, so the new URL for the HOWTO is https://github.com/pauln/moodle-theme_decaf_green/wiki/Inheriting-from-Decaf.  If Mary or Miriam reads this, can you please update the URL in the first post (if possible)?

Cheers,
Paul


P.S. Any of you who have working copies of Decaf Green might want to update your Git remotes to point at the new repo URL - just change "MaxThrax" to "pauln" in the URL.

Average of ratings: Useful (2)
In reply to Paul Nicholls

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by Miriam Laidlaw -
Picture of Plugin developers

Done. Thanks for keeping us up-to-date. smile

In reply to Paul Nicholls

Re: HOWTO: Get the Awesomebar in your theme by inheriting from Decaf

by Sam Thing -

10 months later and I have a working awsomebar from this method and am ready to roll it out on a live site.

Decaf settings have moved on since this howto so I had a go at updating them for my theme. It's all seems fine so I'm posting it here for anyone else who wants a go.

Find and open: /moodle/theme/decaf/settings.php

now edit every line that begins with:

$name = 'theme_decaf/.....

and simply replace every instance of decaf with your theme name:

$name = 'theme_my_theme/....

Save this to /moodle/theme/my_theme/settings.php making sure you've backed up the original settings.php in case it all goes pear shaped.

I'm no developer and have only tried this on my test site so if you have a go your mileage may vary.

Cheers.