Which components can be customized in a theme?

Which components can be customized in a theme?

by Ole Frank Jensen -
Number of replies: 13

I was wondering which components I am able to customize within a theme. I don't want to change any moodle core code as I want to preserve the possibility to update.

As an example: Is it possible to create a custom calendar component? Lets say, insert a clock made with javascript. If it's possible, could you please outline the steps required, ie. which files to change etc. Or point me to a link with relevant info?

The reason I'm asking is that the calendar folder apparently is not a "module" (placed inside the /mod folder). 

BTW, what's the difference between "modules", "plugins", "blocks", "activities"... ?

Cheers, Ole

Average of ratings: -
In reply to Ole Frank Jensen

Re: Which components can be customized in a theme?

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

The code is open source so, with the right amount of skill, you can customize whatever you want.

For a javascript clock, you might look at the generico plugin - allows all sorts of code to be inserted in various places

What can be customized within a theme is dependent on the theme.  Again, if you are writing the theme, you can make it do a lot...

Mods = activities

Blocks = the blocks that you see on the side of the screen

Plugins = everything that is added including mods/blocks/themes etc

In reply to Emma Richardson

Ang: Re: Which components can be customized in a theme?

by Ole Frank Jensen -

@Emma

Thanks for the reply but I think you are missing the point of my question... Just because all code is open doesn't mean it's a good idea to modify it. Because I might loose the ability to update to a newer version of moodle etc. That's why someone invented "themes" = a modifiable  layer separate from the "core" code (which can then be kept untouched).

/ Ole

In reply to Emma Richardson

Ang: Re: Which components can be customized in a theme?

by Ole Frank Jensen -

I found this link useful explaining the three key terms https://docs.moodle.org/32/en/Moodle_key_terms

It seems that calendar is a "block" component. But why isn't it placed under /blocks/calendar (instead of /calendar) then?? And where should I place my custom calendar in my theme? /theme/blocks/mycal ? It could seem that blocks are not part of themes at all.

Also, I found this (https://docs.moodle.org/dev/Blocks) but it seems only valid for moodle v2 (I'm on 3.2)...

In reply to Ole Frank Jensen

Re: Ang: Re: Which components can be customized in a theme?

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Blocks are plugins that can be added separately without affecting core.  Calendar is an integral part of core moodle which is probably why it is not listed as a plugin but you could definitely write a calendar plugin and just add that block to the page.  Blocks still work in the latest version of Moodle.  They apparently have not changed the documentation but I believe the basics should still be the same.

In reply to Emma Richardson

Re: Ang: Re: Which components can be customized in a theme?

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

I believe the block you have seen or are looking for is the mini-calendar (ie block/calendar_month) view while the /calendar folder itself is the full function of the calendar which you get when you click the 'Goto Calendar' link on the Upcoming Events block for example.

You could quite easily clone that calendar_month block and add your clock to it, but as Mary has already said, you can also add it directly to your theme and then dont need to rely on the calendar block being on each page.


In reply to Ole Frank Jensen

Re: Ang: Re: Which components can be customized in a theme?

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

Hi,Yes you can add a clock to any page using a theme, I did this and it is dead easy to do.  The only thing is my computer crashed well and truely last week and although I thought I had all my themes safe, when recovering all my data, I must have missed off preserving certain file types as all the PHP code has been stripped from every theme I had saved that was not in a zip file.

I am not sure if I still have the theme with the clock, but I'll have a look.

Cheers

Mary

In reply to Ole Frank Jensen

Re: Which components can be customized in a theme?

by Fernando Acedo -
Picture of Plugin developers Picture of Testers

The easiest way is to create a custom HTML block and add the code there.

Create a new block could take more time but it is the right way.

Other option is to add some of the existing blocks. Just take a look to the Moodle plugins directory.


In reply to Ole Frank Jensen

Re: Which components can be customized in a theme?

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

Hi Ole,

You can change some elments of the main calendar page using a renderer.

I did just that in the GoLogo theme I made for Moodle 3.2. It is based on the More theme which is a Bootstrapbase theme.

It was only a simple change to the layout of the small calendars that are displayed in the side block region of the page. I added separate classes to the blocks that allowed them to be displayed above the main calendar.

You can see the changes HERE

There are Moodle Developer Docs about Themes and how to customize them in a links at the top of the Themes Forum.

Hope this helps.

Mary

In reply to Mary Evans

Ang: Re: Which components can be customized in a theme?

by Ole Frank Jensen -

Thank you to all for answering my noob questions. Much appreciated smile

Here's another one: which versions of moodle supports Boost Theme? I can't find any info in the docs ( https://docs.moodle.org/32/en/Boost_theme )

BTW: I completed the "How to make a Block" tutorial and it works fine for 3.2.


In reply to Ole Frank Jensen

Re: Ang: Re: Which components can be customized in a theme?

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

Boost is available from Moodle3.2 onwards.

It will not work 3.1 or earlier

In reply to Richard Oelmann

Ang: Re: Ang: Re: Which components can be customized in a theme?

by Ole Frank Jensen -

OK so if I want to make a customized theme for moodle 2.x, which theme is the best starting point? "Clean", "More", "Bootstrapbase", ...?

Also: in "Boost" it's possible to customize the admin settings pages in the custom template files. Is this possible to do in other themes as well?

As far as I can see Boost is the only theme using SCSS and Mustache?

In reply to Ole Frank Jensen

Re: Ang: Re: Ang: Re: Which components can be customized in a theme?

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

Boost is the only core theme using SCSS and Mustache (and Bootstrap4) - Clean and More use LESS and Bootstrap2.

There are a couple of Boost based themes in the plugins database (Photo and Waxed are good starting points for further development, while Fordson is a fully featured theme). There are also some notes around a pico presentation I did at the UK Moot earlier this month at https://www.slideshare.net/RichardOelmann/moodle-moot-ieuk-2017-creating-a-child-theme-for-boost

There are also a couple of themes that use Bas Brand's theme_bootstrap as a base/parent using Bootstrap3.

Boost is the way forward but I'm personally not convinced its ready for full production yet (that's not a comment on the theme itself, but on the fact that the upstream BS4 is still in alpha), but if you are happy to take on that overhead, then its certainly the direction HQ are heading. That said, I'm the author of Waxed and am working on few other Boost based themes as personal learning projects for development, so quite happy to join this journey smile


Richard