Nimble Drop Down Menus ... dyanamic?

Nimble Drop Down Menus ... dyanamic?

by Adam Morris -
Number of replies: 2

I am using Moodle for a school's coursework and they think that having a drop-down menu of every course a kid is signed up to would be really great. I'm using the Nimble theme.

I tried going the server-side includes route but the Moodle won't let me insert tags for obvious security reasons.

So, can I somehow someway have it so that I can have Nimble theme with a dynamically-generated list? Maybe a plug-in that can help me do that? Anything? Try a different forum maybe?

Average of ratings: -
In reply to Adam Morris

Re: Nimble Drop Down Menus ... dyanamic?

by Miriam Laidlaw -
Picture of Plugin developers

There is a way to get a custom menu in your theme if you have access to the theme files.

I haven't looked at Nimble myself to see what there is, but if it doesn't already have something similar you might be looking at changes in the theme's:

  • config.php
  • renderers.php

In config.php you need to have the line:

$THEME->rendererfactory = 'theme_overridden_renderer_factory';

And in renderers.php

<?php
 
class theme_nimble_core_renderer extends core_renderer {

// --- Start of custom menu modifications --- //
 
    protected function render_custom_menu(custom_menu $menu) {

// Adds the "My Courses" drop down to the custom menu if user is
// logged in AND enrolled in some courses.

        $mycourses = $this->page->navigation->get('mycourses');
        if (isloggedin() && $mycourses && $mycourses->has_children()) {
            $branchlabel = get_string('mycourses');
            $branchurl   = new moodle_url('/course/index.php');
            $branchtitle = $branchlabel;
            $branchsort  = 9999;
            $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
            foreach ($mycourses->children as $coursenode) {
                $branch->add($coursenode->get_content(), $coursenode->action, $coursenode->get_title());
            }
        }

// Finishes the custom menu.

        return parent::render_custom_menu($menu);
    }

// --- End of custom menu modifications --- //


}

For more detailed instructions on overriding renderers in a theme, see this tutorial.

Average of ratings: Useful (2)