Customising Course Themes and menus in Moodle 2

Customising Course Themes and menus in Moodle 2

by David Myers -
Number of replies: 14

I am experimenting with Moode 2 and have downloaded the Arctic theme. I have created customised drop-down menus for the front page but what I would like to do is create a clone of the front page theme for each of the courses /categories and then create course-specific drop-down menus rather than the site-wide drop-down menu items that were on the home page.

Is this posible and, if so, how.

Thanks

David

Average of ratings: -
In reply to David Myers

Re: Customising Course Themes and menus in Moodle 2

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

It would certainly be possible to create clones of the main theme, renamed in all the relevant places, with customised menus for each course and then apply a specific theme to each course, although this would seem a rather cumbersome, but workable way of achieving the aim.

Possibly someone with a bit more coding knowledge within Moodle may be able to suggest a conditional statement to test the courseid and select an appropriate menu file with the customised menu.

However, have you considered the alternative of keeping the site wide drop down menus as they are and using the Topic0 section of the course to provide the internal course-specific navigation?

 

Richard

In reply to David Myers

Re: Customising Course Themes and menus in Moodle 2

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

This can't be done with the Moodle custom menu the way it is coded at present, although I suspect it could be made to work like you want it without having to 'clone' the theme.

Basically, to make the custom menu work, the way you want it to, first it will need some id selectors adding to the various parts of the menu structure. And then some code putting in the renderer.php to govern the way it works. Easier said than done.

Making clones wont solve anything, as the custom menu is site wide, so what's in the menu will be written into the d/down menu on whatever page your site dictates it should be available in.

You could create a new layout page for course/category (you only need to make one) but it would have to be declared in the Arctic's config.php file.

This layout could have a separate (manual) dropdown menu which could be included into the course/category page. This would follow the same structure of the YUI dropdown menu in Base YUI (Moodle 1.9 Theme) by Patrick Malley.

Depending on what you want to add to each course/category page would need to be determined as it could be quite a time consuming thing to create.

What Richard suggest might be a better option. As all you would need to do is add the basic structure of the menu a an unordered list and then add some style to it in the css file for the theme.

You might like to look at the type of menus you could use HERE.

Hope this helps?

Mary

Average of ratings: Useful (1)
In reply to Mary Evans

Re: Customising Course Themes and menus in Moodle 2

by David Myers -

Thanks for the help - It look as though the Topic 0 menu items might be the most sensible way to go.

David

In reply to David Myers

Re: Customising Course Themes and menus in Moodle 2

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

Hi David,

Just tried this out using the Pure CSS Hover list from Mary's suggested link, although the principle would be the same whichever list you choose, or writing your own from scratch.

  • Copy the html for the list into Topic0 of the course
  • Create a new css file in the Style folder of the theme, copying the css for the list
  • Add the new css file to the $THEME->sheets = array section of the config.php file

Obviously you will need to manually edit the menus for each course, but the css file will give them a consistent look across the site, which you would need to create by editing the css given to achieve the style you want.

Hope that helps

Richard

In reply to David Myers

Re: Customising Course Themes and menus in Moodle 2

by Mat Cannings -

Hi David,

With the new theming it is possible to override renderers in a theme. If you are fairly comfortable with PHP it is possible to override the function render_custom_menu().

You could then program it to draw a menu to your own specs wherever that theme is used.

Following the instructions here http://docs.moodle.org/en/Development:Themes_2.0_overriding_a_renderer I have a theme that has a custom menu and a custom breadcrumb trail by overriding the function navbar().

Average of ratings: Useful (2)
In reply to Mat Cannings

Re: Customising Course Themes and menus in Moodle 2

by Nyree Williams -

Hello

Is it possible to hide the custom menu before login?

thanks

In reply to Nyree Williams

Re: Customising Course Themes and menus in Moodle 2

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

Yes it is Nyree.

In the layout files (frontpage.php, general.php, default.php - depending on your theme) you would need to chasnge theline with echo $custommenu to be wrapped in an if statemnt
. If you can tell me what theme you are using I will try to be specific and give you the actual code to use. in that theme

Richard

In reply to Richard Oelmann

Re: Customising Course Themes and menus in Moodle 2

by Nyree Williams -

Thanks for replying Richard,
I'm using the formal white theme

Nyree

In reply to Nyree Williams

Re: Customising Course Themes and menus in Moodle 2

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

Hi Nyree,

In formal white, the bit you are looking for is this

            <?php if ($hascustommenu) { ?>
                <div id="custommenu"><?php echo $custommenu; ?></div>
            <?php } ?>

which needs to be changed as below in both the general.php and the frontpage.php

            <?php if ($hascustommenu) { ?>
                if (isloggedin()){ <div id="custommenu"><?php echo $custommenu; ?></div>}
            <?php } ?>

 

HTH

Richard

In reply to Richard Oelmann

Re: Customising Course Themes and menus in Moodle 2

by Nyree Williams -

Hi Richard
Thanks for this...
I did what you said in both files:
<!-- begin of custom menu -->
               <?php if ($hascustommenu) { ?>
                if (isloggedin()){ <div id="custommenu"><?php echo $custommenu; ?></div>}
            <?php } ?>
<!-- end of custom menu -->

but I still have the menu and a bit of the code appearing (see attached)
Should there be something else before the 'if'?thoughtful

Nyree

Attachment Capture.PNG
In reply to Nyree Williams

Re: Customising Course Themes and menus in Moodle 2

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

Sorry Nyree, my mistake - you need to move the <?php....?> tags as well, as the if statement is also php code - the bits I've highlighted in red need to be deleted and the bits in green added

<!-- begin of custom menu -->
      <?php if ($hascustommenu) { ?>
          if (isloggedin()){ ?> <div id="custommenu"><?php echo $custommenu; ?></div> <?php }
            <?php } ?>
<!-- end of custom menu -->

So that it looks like this (I've split the lines as well to show the nesting of the if statements more clearly)

<?php if ($hascustommenu) {
         if (isloggedin()){ ?>
                 <div id="custommenu"><?php echo $custommenu; ?></div>
         <?php }
} ?>
 

Sorry for the confusion caused - trying to do this with only intermittent internet access, my failing memory and no webserver at the moment smile

Richard

In reply to David Myers

Re: Customising Course Themes and menus in Moodle 2

by imketu p -

Any one can help to customise course subcategory inmoodle 2.1.2

i would like to change font size and colour of sub-category and use some image in front. i dont know where to change.

i have looked in to core file course/category.php that display course and sub-category list but no clue to change where.

 

               $catlinkcss = $subcategory->visible ? '' : ' class="dimmed" ';
                echo '<a '.$catlinkcss.' href="category.php?id='.$subcategory->id.'">'.
                     format_string($subcategory->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $subcategory->id))).'</a><br />';

i want to make like

insted of

 

thanks

 

 

 

In reply to imketu p

Re: Customising Course Themes and menus in Moodle 2

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

Hi,

You would do this by changing the CSS in the theme.

But as all the CORE themes use BASE theme the need to carry the CSS for categories/courses is minimised so you may not even find the CSS you need, in your temes's style directory.

The best thing to do is to use Firebug this will enable you to find the CSS you need then all you have to do is copy it and paste to the end of the core.css for your theme (if core.css exists).

HTH

Mary