Themes

 
 
Sam@moodle
Moodle 2.0: Custom menu in core
Group DevelopersGroup Moodle HQGroup Particularly helpful Moodlers
Hello everyone,

As per MDL-22398 there is now support for a drop down menu within Moodle 2.0 (called a custom menu).

MDL_22398.screenshot.png

The screenshot above shows the menu in action on the standard theme.

How it works
The custom menu is a drop down menu that makes use of the YUI3 menunav widget to produce a smart drop down menu when JavaScript is enabled and minimal CSS to display and function (in modern browsers) when it is disabled. Within Moodle it is implemented as a component and is produced by the core renderer.
What this all means is that you can now have a fancy drop down menu that will work cross browser with JavaScript enabled or disabled.
Because it is produced by the core renderer those of you who want to use a different drop down menu system will be able to do so by overriding the core renderer.

How to add a custom menu
First up the theme you are using needs to support it!
To set up the custom menu log in to your site as an admin and browse to the following in the settings block:

Administration > Appearance > Themes > Theme settings

On that screen you will see right down the bottom a textarea to set custom menu options and an example of how to set it below.
Simply write you custom menu out into that box as explained in the example, save, and presto you have a custom drop down menu.... Hoorah.

How to add custom menu support to your theme
Adding a custom menu to your own theme is pretty simple once you understand the basics of creating a theme within Moodle 2.0.
The following is based on the way in which the base/standard themes are implemented.

Step 1.
Within your layout file(s) you need to first determine if a custom menu has been created. You can do so in the following manor:
<?php
$custommenu = $OUTPUT->custom_menu();
$hascustommenu = (empty($PAGE->layout_options['nocustommenu']) && !empty($custommenu));
?>
This gets us two things, first the content for the custom menu $custommenu, the second a boolean to tell us whether we should display the custom menu $hascustommenu. You will notice that $hascustommenu is determined by two checks, obviously we check if there is a custommenu that isn't empty, and we need to check if the layout wants a custommenu so we have a new layout option nocustommenu that can be set for a layout where we dont want to show the custom menu (I would recommend setting this for Maintenance, Embedded, and Popup initially).

Step 2
.
Within that same file we need to display the custom menu if $hascustommenu is true... so add the following code right above the navbar (or where ever you want to display it).
<?php if ($hascustommenu) { ?>
 <div id="custommenu"><?php echo $custommenu; ?></div>
<?php } ?>
This code is pretty simple, first we check that $hascustommenu is true and if it is we echo $custommenu into a div with the id=custommenu.

And that is it!

There is one more thing you should be aware of however, you will need to add some special CSS in order to get the menu to display nicely if JavaScript is disabled and when the page first loads. This is because:
  • The widget only works with JavaScript by default, if it is disabled you just see a normal indented list.
  • The menu doesn't get initialised immediately, you have to wait for the page to load and the JavaScript to execute at which point the menu will jump into place.
Obviously this isn't desired! so the solution I have implemented is to add a 'javascript-disabled' class to the first div that is part of the menu. This class gets removed as soon as the menu is initialised by JavaScript. So when the page first loads, or if JavaScript is disabled you will see this class.
The class allows you to write CSS that will NOT conflict with the YUI css to make sure that the menu displays correctly before the menu is initialised or if JavaScript is disabled.

If in doubt look at what the base and standard theme are doing.

Feel free to ask any questions, but before any one asks I will certainly update the theme's documentation shortly.

Cheers
Sam

P.S Kudo's to Patrick and Martin for agreeing to implement this in core.


 
Average of ratings:Useful (8)
Goatee
Re: Moodle 2.0: Custom menu in core
Group Developers
This looks great, Sam. Thanks for your quick work!
 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers
Hi Sam,

I have just implemented this on my Moodle 2.0 Flower Power theme on my own computer and it works! I just need to tweak the CSS to make it go where I want it to, but on first view it's an excellent addition to any theme and available to anyone who wishes to use it.

Simples! smile

 
Average of ratings: -
Picture of Danny Wahl
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Particularly helpful Moodlers
this is great, it's very similar to what we have implemented in our site, but I would ask if it would be possible to add one or two capabilities.

1) check if a user has the capability to view the menu, something like this:
 if ($hascustommenu && has_capability(moodle/site:viewcustommenu) { //display custom menu }  

so that I don't have to use the "legacy function" to hide it from guests/roles:
 if ($hascustommenu && !(has_capability(moodle/legacy:guest || has_capability(moodle/legacy:student)) { //display custom menu }  
2) it would be nice to, say be able to make sure that the menu/item is only available to people with permissions, say it has resources or something that we only want them to have. In addition (this is a pipe-dream) if there could be a delimiter for a second capability, something like has_capability(moodle/site:viewhiddencustommenu) so that if there were a menu like this:

Moodle community|http://moodle.org
-Moodle free support|http://moodle.org/support
-*Secret Menu|http://moodle.org/secret

users with the capability to see the items with a * will see them, users without, won't.

Again, thanks and great work.
 
Average of ratings: -
Goatee
Re: Moodle 2.0: Custom menu in core
Group Developers
Hello Daniel,

We're definitely not done with this menu; our goal was to get a simple menu implementation out there for 2.0 and we'll definitely improve it from there. Will you please add these suggestions as separate improvements to the tracker? I think they are both great ideas.
 
Average of ratings: -
Picture of Danny Wahl
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Particularly helpful Moodlers
Patrick,

Just wanted to let you know I got those tickets in. Sorry it took so long:

1) http://tracker.moodle.org/browse/MDL-22482

2) http://tracker.moodle.org/browse/MDL-22483
 
Average of ratings: -
Goatee
Re: Moodle 2.0: Custom menu in core
Group Developers
Hey Sam,

You include the CSS from /skins/sam/ in the YUI menu. Why not just include the node-menunav-core.css file and add a menunav file to the theme?

Using node-menunav.css loads colors, backgrounds, and borders that designers will have to overwrite if they don't want to use them.
 
Average of ratings: -
Sam@moodle
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Moodle HQGroup Particularly helpful Moodlers
Hi Patrick,

Currently the YUI3 loader is automatically including the CSS it sees as necessary for the menu nav widget.

I've just created MDL-22450 to see about possibly finding a solution to this. I'm not overly familiar with the YUI loader but if I can find a minute I'll see what I can pull out of the hat.

Cheers
Sam
 
Average of ratings: -
Picture of Andreas Stoeffer
Re: Moodle 2.0: Custom menu in core
 
Hello Sam,

working with Moodle 2.0 an the new theme options I saw the possibility to add a custom menu.
It works good and is a long wanted feature.

Will it be possible in the future to add dynamic entries, i.e "my courses"?
When a user is logged in, the menu will be filled with all courses the user is enrolled in.
That would be great smile

Best regards
Andreas
 
Average of ratings: -
Sam@moodle
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Moodle HQGroup Particularly helpful Moodlers
Hi Andreas,

Presently the custom menu is very "much what you see is what you get" and what you are asking about is not immediately possible.

That being said the custom menu is produced by a renderer, so really at the end of the day anything is possible.

Among many other things over the past couple of weeks I have been putting converting the moodle.org theme to a Moodle 2.0 theme. Part of the process is to further customise the custom menu to do two additional things.
  1. Integrate a my courses branch in the menu (exactly what you are asking for).
  2. Use strings from a language pack as the label for the menu items rather than fixed strings allowing the custom menu to support multiple languages.


Providing Martin is OK with me doing so I will write a quick tutorial in Moodle docs on this shortly for you, and anyone else who may be interested.

Cheers
Sam
 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers
Hi Sam,

I for one will be looking out for the tutorial...thanks in advance!

I was trying, the other day, will little or no success, to integrate a Moodle 1.9 menu system which puts categories and courses into a drop-down menu which uses YUI2 js files available in Moodle 2.0.

I got it all set up, general.php and frontpage.php files all done and checked and set to go. But when I refreshed the screen, the only thing I got was a notice saying that the php 'count' (which is used in the code for the dynamic menu) was no longer available under Moodle 2.0.

I've attached the php file to this post for to look at if you have the time...but here is the part which uses the count....

if ($categories = get_child_categories($category->id)) { // Print all the children recursively
$countcats = count($categories);
$count = 0;
$first = true;
$last = false;
foreach ($categories as $cat) {
$count++;
if ($count == $countcats) {
$last = true;
}
$up = $first ? false : true;
$down = $last ? false : true;
$first = false;

print_whole_category_list_menu($cat, $displaylist, $parentslist, $depth + 1, $files);
echo '</ul></li>';
}
}

My question is...is there an alternative method I could incorporate into this code to make it work in Moodle 2.0? Or are Moodle 2.0 categories and courses set up differently that this code would not work anyway even with a different counter?

Many thanks for your time, which I know is precious!

Mary
 
Average of ratings: -
Sam@moodle
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Moodle HQGroup Particularly helpful Moodlers
Hi Mary,

At a glance the code looks OK, the count method is a PHP method not a Moodle method so I wonder if it is because of what $categories is being set too by the get_child_categories method.

I'm more than happy to help out but will probably need a bit more information, could you please do the following:

1. Turn on debugging so we get all the details.

2. Can you copy and paste of better yet screen shot the error message you are getting and attach it here.

3. Try adding the following lines of code immediately before the count that is causing the error.
 
echo "
";
var_dump($categories);
var_dump($category);
try {
    count($categories);
} catch(Exception $e) {
    print_object($e);
}
echo "
";


Hopefully something there will provide the clue smile

Cheers
Sam

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers
Hi Sam,

Thanks for replying. I've done as you said, and have copied the of data from the debug dump (which made a little bit of sense - but not much! LOL) and uploaded here as a text file.

Any help with this would be most welcome. As you can see from the screen shot of the error message it's not very helpful, but might make sense to you. The flag in the header, by the way, is generated by the script you wrote for changing logo on language change! I currently have EN, IT, FR language packs with corresponding flags in pix folder. smile - Many thanks - Mary

count-error.jpg
 
Average of ratings: -
Sam@moodle
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Moodle HQGroup Particularly helpful Moodlers
Hi Mary,

Thank you for the debug information, indeed upon closer inspection there was a fair bit wrong with this script, the code below tidies it up (a little).

 
$text = '<a class="yuimenubaritemlabel" href="'.$CFG-"><img width="18" height="17" src="'.$CFG-" alt="Home" title="Home" /></a>';
$text .= '';
echo $text;

print_whole_category_list_menu();

function print_whole_category_list_menu($category=NULL, $displaylist=NULL, $parentslist=NULL, $depth=-1, $files = true) {
    /// Recursive function to print out all the categories in a nice format
    /// with or without courses included
    global $CFG;

    if (isset($CFG->max_category_depth) && ($depth >= $CFG->max_category_depth)) {
        return;
    }

    if ($category) {
        if ($category->visible or has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM))) {
            print_category_info_menu($category, $depth, $files);
        } else {
            return;  // Don't bother printing children of invisible categories
        }
    } else {
        $category->id = "0";
    }

    if ($categories = get_child_categories($category->id)) {   // Print all the children recursively
        $countcats = count($categories);
        $count = 0;
        $first = true;
        $last = false;
        foreach ($categories as $cat) {
            $count++;
            if ($count == $countcats) {
                $last = true;
            }
            $up = $first ? false : true;
            $down = $last ? false : true;
            $first = false;

            print_whole_category_list_menu($cat, $displaylist, $parentslist, $depth + 1, $files);
            echo '';
        }
    }
}

function print_category_info_menu($category, $depth, $files = false) {
    /// Prints the category info in indented fashion
    /// This function is only used by print_whole_category_list() above
    global $CFG, $DB;
    $coursecount = $DB->count_records('course') <= FRONTPAGECOURSELIMIT;

    $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.summary');
    if ($depth) {
        if ($category->visible) {
            echo '<a class="yuimenuitemlabel" href="'.$CFG-">'.format_string($category->name).'</a>';
        } else {
            echo '<a class="
yuimenuitemlabel invisiblecategory" href="'.$CFG-">'.format_string($category->name).'</a>';
        }
    } else {
        if ($category->visible) {
            echo '<a class="yuimenubaritemlabel" href="'.$CFG-">'.format_string($category->name).'</a>';
        } else {
            echo '<a class="
yuimenubaritemlabel invisiblecategory" href="'.$CFG-">'.format_string($category->name).'</a>';
        }
    }


    if ($files and $coursecount) {
        echo '
 
 
';

        if ($courses && !(isset($CFG->max_category_depth)&& ($depth>=$CFG->max_category_depth - 1))) {
            foreach ($courses as $course) {
                if ($course->visible) {
                    echo '
<a class="yuimenuitemlabel" href="'.$CFG-">'.format_string($course->fullname).'</a>';
                } else {
                    echo '
<a class="yuimenuitemlabel invisiblecourse" href="'.$CFG-">'.format_string($course->fullname).'</a>';
                }
            }
        }
    }
}
 

I made the following changes to the code in order to get it working:
 
Converted the database calls to make use of the new database API ($DB->)Removed several fields from the DB call to get a categories courses (these have been moved to the enrolment plugins they belong to and weren't needed anyway)Removed excess params being passed to functions. i.e. function takes 5 args, call had 6

Alternatively try this bit of code instead of what you are using now. I converted it to a class + Moodle 2 API'
s. I had to guess a bit of what you are trying to do and how it looks like it should work. Hopefully you should just need to wrap it in an UL tag with the right classes/id and then call what ever JS you were calling before.

 
<code>
require_once($CFG->dirroot.'/course/lib.php');
$menu = new category_course_menu();
$menu->display();

class category_course_menu {

    protected $nested = true;
    protected $structure = null;

    /**
     * Creates the new category_course_menu object
     *
     * @param bool $nested If set to true (default) categories as nested, otherwise
     *                      sub categories are just added after thier parent.
     */

    public function __construct($nested=true) {
        $this->nested = (bool)$nested;
        $this->structure = get_course_category_tree();
    }

    /**
     * This generates the HTML for the menu and returns it. You must echo the result to display.
     *
     * @param core_renderer $output
     * @return string HTML
     */

    public function display(core_renderer $output) {
        $text = '';
        $text .= html_writer::start_tag('li', array('class'=>'yuimenubaritem first-of-type'));
        $text .= html_writer::link(
                    new moodle_url('/'),    // href
                    $output->pix_icon('menu/home_icon','Home','theme', array('title'=>'Home','style'=>'width:18px;height:17px;')), // The icon
                    array('class'=>'yuimenubaritemlabel')); // attributes for the a tag
        $text .= html_writer::end_tag('li');

        foreach ($this->structure as $category) {
            $text .= $this->render_category($output, $category);
        }

        return $text;
    }

    protected function render_category(core_renderer $output, $category, $depth=0) {

        $liclass = ($depth > 0)?'yuimenuitem':'yuimenubaritem';
        $aclass = ($category->visible)?$liclass.'label':$liclass.'label invisiblecategory';

        $text = '';
        $text .= html_writer::start_tag('li', array('class'=>$liclass));
        $text .= html_writer::link(
                    new moodle_url('/course/category.php', array('id'=>$category->id)),    // href
                    format_string($category->name),
                    array('class'=>$aclass)); // attributes for the a tag

        if ($this->nested && count($category->categories) > 0) {
            $text .= html_writer::start_tag('div', array('yuimenu'));
            $text .= html_writer::start_tag('div', array('db'));
            $text .= html_writer::start_tag('ul');
            foreach ($category->categories as $cat) {
                $text .= $this->render_category($output, $cat, $depth+1);
            }
            $text .= html_writer::end_tag('ul');
            $text .= html_writer::end_tag('div');
            $text .= html_writer::end_tag('div');
        }

        if (count($category->courses) > 0) {
            $text .= html_writer::start_tag('div', array('yuimenu'));
            $text .= html_writer::start_tag('div', array('db'));
            $text .= html_writer::start_tag('ul');

            foreach ($category->courses as $course) {
                $text .= $this->render_course($output, $course);
            }

            $text .= html_writer::end_tag('ul');
            $text .= html_writer::end_tag('div');
            $text .= html_writer::end_tag('div');
        }

        $text .= html_writer::end_tag('li');

        if (!$this->nested && count($category->categories) > 0) {
            foreach ($category->categories as $cat) {
                $text .= $this->render_category($output, $cat);
            }
        }

        return $text;
    }

    protected function render_course(core_renderer $output, $course) {
        $liclass = 'yuimenuitem';
        $aclass = ($course->visible)?$liclass.'label':$liclass.'label invisiblecourse';
        $ahref = new moodle_url('/course/view.php', array('id'=>$course->id));

        $text = '';
        $text .= html_writer::start_tag('li', array('class'=>$liclass));
        $text .= html_writer::link( $ahref, format_string($course->fullname), array('class'=>$aclass));
        $text .= html_writer::end_tag('li');

        return $text;
    }
}
 
 

Hope this helps

Cheers
Sam
 
 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers
Thank you Sam!

I'll try them out and see which works the best, and report back.

I like the look of the second one, as this, on reading it, looks like it will do the job nicely.

Many, many thanks
Mary
 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers
Hi Sam,

More feedback after testing both menu scripts.

The 1st menubar.php (renamed samsmenubar.php) got a parse error at line 52, which turned out to be a missing line from the original code. I fixed that and tried again but it stopped with...

Coding error detected, it must be fixed by a programmer:
PHP catchable fatal error

So I tried the 2nd menu.php, the one you created (renamed samsmenu.php), this stopped at about the same place with same error notice as above.

Both debug listings attached in one uploaded text file.

Getting there...slowly smile

Thanks again for your time,

Mary

 
Average of ratings: -
Sam@moodle
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Moodle HQGroup Particularly helpful Moodlers
Hi Mary,

First up the error with samsmenu.php the one I created, the following line
 
$menu->display();
 

Should be
 
$menu->display($OUTPUT);
 


Second the error with the original code, the debug for that is a little more cryptic, but I think the problem may be the code I posted, it appears it removed some > characters from the code I posted.
Could you please check on the very first line of that file whether you have:
 
$CFG-wwwroot
// and
$CFG-httpswwwroot
 

If you do you need to add > characters back in to get:
 
$CFG->wwwroot
// and
$CFG->httpswwwroot
 


Let me know how those two changes go.

Cheers
Sam
 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers
Hi Sam,

Thanks for the reply. I fixed all the errors in both php files.

After I corrected the $menu->display($OUTPUT); in samsmenu.php it worked, no errors, but it's not showing any categories or courses in the menu, although the page appears to be perfect in every respect. Docking works...nothing looks amiss...just no menu items in the otherwise correctly styled menu bar! sad

The original menubar you tidied up, even after I put back all the > it's still giving out debugging error messages with the same Fatel Error notice as before....here they are.

Coding error detected, it must be fixed by a programmer: PHP catchable fatal error

Debug info: Object of class stdClass could not be converted to string
Stack trace:
  • line 271 of \lib\setuplib.php: coding_exception thrown
  • line 62 of \theme\cafelite\layout\samsmenubar.php: call to default_error_handler()
  • line 20 of \theme\cafelite\layout\samsmenubar.php: call to print_category_info_menu()
  • line 42 of \theme\cafelite\layout\samsmenubar.php: call to print_whole_category_list_menu()
  • line 7 of \theme\cafelite\layout\samsmenubar.php: call to print_whole_category_list_menu()
  • line 63 of \theme\cafelite\layout\general.php: call to include()
  • line 622 of \lib\outputrenderers.php: call to include()
  • line 580 of \lib\outputrenderers.php: call to core_renderer->render_page_layout()
  • line 146 of \my\index.php: call to core_renderer->header()
Mary
 
Average of ratings: -
Sam@moodle
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Moodle HQGroup Particularly helpful Moodlers
Hi Mary,

It looks like it is the same problem again with the missing >'s.

At a glance I can see at least 8 more instances where it's removed the >. If you search the file for the following you should be able to find and replace them all:

 
$CFG-wwwroot
 


Cheers
Sam
 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers
Hi Sam,

It can't be that as I caught all 8 instances 7 $CFG->wwwroot and 1 $CFG->httpswwwroot

However, in looking at the script again this morning, I am beginning to wonder if the parse error I mentioned earlier is something to do with it.

In your script, which I copied and used first time, a parse error occurred at line 52 which was this line...(single bracket at the end of the line)
global $CFG, $DB;
$coursecount = $DB->count_records('course') id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.summary');

I looked at the original script I had, (which works OK in Moodle 1.9.9), and found that line 52 was missing some data which I copied and then added to your version...see highlighted section. Is this what could be causing the problem? Given that all the > errors were fixed?

global $CFG, $DB;
$coursecount = $DB->count_records('course') <= FRONTPAGECOURSELIMIT;
$courses = get_courses($category->id,'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.summary');
if ($depth) {

... etc.,

Mary




 
Average of ratings: -
Sam@moodle
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Moodle HQGroup Particularly helpful Moodlers
Hi Mary,

Yes indeed, it appears Moodle has gone and trimmed bits of the code I posted, probably for security but how annoying is that!

I'll rebuild the code when I get a minute and attach files rather than posting the code this time.

Sorry for the confusion.

Cheers
Sam
 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers
Moodle is like that! LOL but we live with it! smile

I'm in no hurry...I appreciate the time you have spent on this already...when other more important programming is needed...this can wait! Truely


Mary


 
Average of ratings: -
自己
回复: Re: Moodle 2.0: Custom menu in core
 

我想知道moodle的主题是怎么加载的????

 
Average of ratings: -
Picture of Bonnie Mioduchoski
Re: Moodle 2.0: Custom menu in core
 

Hi Sam,

I wonder if you might know the answer to this - I have a menu bar that runs across the top of our course. However, to view those you have to be logged in. I would like a "Support" page that would be accessible before a user logs in. Is there a way to do this?

This page already exists on our website and the "menu" item would be more of a link than a page. Is there anyway to link to an existing web page outside of moodle but have it appear as a menu on moodle?

Thanks in advance, Bonnie


 
Average of ratings: -
Sam@moodle
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Moodle HQGroup Particularly helpful Moodlers
Hi guys,

I've just created the tutorial, hasn't been spell checked or anything yet... will do that in the next day or two.

Development:Themes 2.0 extending the custom menu

I should add this is moderate to advanced difficulty.

Any questions feel free to ask them this forum.

Cheers
Sam
 
Average of ratings: -
Picture of Levi Smith
Re: Moodle 2.0: Custom menu in core
 

Thanks for the information. This was a much needed/wanted feature. Anyway, I'm trying to figure out how to change the "target" of the links, so that they will open in a new window, but I can't seem to get it working. Any suggestions? Or is this one of those things that just isn't available yet?

Thanks in advance...

Levi

 
Average of ratings: -
Picture of Jason Hammes
Re: Moodle 2.0: Custom menu in core
 

 

Levi,

Did you ever find a solution to changing the target of these custom menu items.  I would like to force them to open in a new window.

Thanks!

 
Average of ratings: -
Picture of Levi Smith
Re: Moodle 2.0: Custom menu in core
 

Jason,

No, I haven't yet. I ended up getting side-tracked with other projects...

I plan on going in to the code, and adding the feature myself; I'll post what I find when I get there...

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Levi,

To enable a link in the custommenu so that it opens into a new window you would need to do the following...

First you have to visualize the outcome for the hyperlink...

Normally this is what you would write to add a hyperlink in a HTML page

<a href="http://google.com" target="new" >Google</a>

but what is actually needed in the custommenu are the parts I have highlighted

Google|http://google.com" target="new"

The same goes for adding Mailto links for email address

<a href="mailto:anyname@yourwebsite.com">Contact</a>

Contact|mailto:anyname@yourwebsite.com

Hope this helps?

Mary

 

PS: Of course 'target' is depreciated in XHTML and so is not Web Standards  compliant as users can decide how they want to see the links by right clicking on the link or from within their browser settings. smile

 
Average of ratings:Useful (1)
Picture of Levi Smith
Re: Moodle 2.0: Custom menu in core
 

Mary,

Thanks a million. That certainly saves me a lot of time. I figured that there was probably some syntax, but I couldn't figure out what it was...

I probably tried every combination of syntax (even for the standard hyperlink add in HTML), but it still wasn't working. I have no idea what my problem was...

Anyway, thanks again...

 
Average of ratings: -
Picture of Jason Hammes
Re: Moodle 2.0: Custom menu in core
 

Thanks Mary! Your help is great on these forums.

Do you know how to make Moodle 2.0 pull up my site regardless of whether users einter the www or not? 

Right now, if people access my site with the www there is not problem, but if they access it without entering the www they get an error message "Incorrect access detected..." and then are auto redirected to the www version.

I would like either to not have the error message and an auto direct or the make it so the site just pulls up regardless.

Thanks!

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

The DNS for your site needs checking, something your hosting company should be able to resolve for you. My own Moodle site can be accessed either as http://www.visible-expression.co.uk or http://visible-expression.co.uk and this is all done by the server. So it's YOUR server which is not set up correctly. Call your host's Support Helpdesk and ask them either to tell you haw to do this, or ask them to do it for you. They should oblige as it's what you pay them for.

By the way what is your website address? If you wish to keep it private then send me a message here and add a link to your site.

Cheers

Mary

 
Average of ratings: -
Head
Re: Moodle 2.0: Custom menu in core
Group Particularly helpful MoodlersGroup Testers

It is my understanding that of Moodle 2 you can only access your site with one URL... And that this error message and redirect is built into Moodle 2 to stop any potential issues that accessing Moodle through different URLs can cause.

Jon

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Well whatever the redirect issue is for James, it's seamless as far as my website is concerned, and I put that down to the way my site is configured server side.

Mary

 
Average of ratings: -
Picture of Dan Zavone
Re: Moodle 2.0: Custom menu in core
 

Mary,

Can you suggest how I might add an image/icon to a menu by using the 'custom menu items' ?.

Have tried a few combinations and I have seen it done but I'm obviously missing something.

Thanks

Dan

 
Average of ratings: -
Picture of Catherine Berry
Re: Moodle 2.0: Custom menu in core
 

I'm trying to extend the custom menu by overriding the renderer. I've followed Sam's instructions to get the My Courses menu, which works perfectly (thank you Sam!).

I now want to add some extra items to my custom menu within my own renderer rather than in the theme settings. I need to do this because I want to add conditionals so that certain menu items are hidden in particular courses or for particular types of user.

I'm having trouble with non-moodle urls.

I've put this in as a test:

$branchlabel = 'BBC website';
$branchurl = 'http://www.bbc.co.uk';
$branchtitle = $branchlabel;
$branchsort = 3;

$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);

This gives me a white page with 'The service is unavailable'. (I've never seen this error message in Moodle 1.9 - what does it mean?)

However, if I change $branchurl to a moodle url using new moodle_url, it works with no problem.

I assume that my syntax is wrong for the url. Can anyone advise?

Many thanks.

 
Average of ratings: -
Picture of Richard Oelmann
Re: Moodle 2.0: Custom menu in core
Group Particularly helpful MoodlersGroup Testers

Catherine,

An easier way to achieve this may be to go back to using one of the yui style menus that were in some of the Aardvark (and other) themes for 1.9 and to build that into your moodle2 theme. I know I and a few other people worked succesfully on putting conditional sections onto this style of menu. I'd be happy to help if you want to do something like that.

Richard

 
Average of ratings:Useful (1)
Picture of Catherine Berry
Re: Moodle 2.0: Custom menu in core
 

Thanks Richard. On our 1.9 site we are using a yui menu - our theme is based on Afterburner.  I wasn't sure how to make it work in 2.0 though. The new theme I'm working on is based on Binarius. If you could give me some hints on how to make my existing menu work in 2.0, or tell me another theme that I could look at that already uses the yui menus, then that would be a lot easier than recreating it using the custom menu.

 
Average of ratings: -
Picture of Richard Oelmann
Re: Moodle 2.0: Custom menu in core
Group Particularly helpful MoodlersGroup Testers

In most of the 1.9 themes that used it the yui menu was a separate php file that was called/'incuded' from the header.html and styled with css.

In 2.0 it should work exactly the same way, except it would be called from the layout file (e.g. default.php) I think you could probably even keep your existing menu file and css and transfer them dirsectly to the moodle2 theme folder.

I'm on my way out to choir right now, but if you would like, I'd be more than happy to take a look at this for you tomorrow sometime.

Richard

 
Average of ratings:Useful (1)
Picture of Catherine Berry
Re: Moodle 2.0: Custom menu in core
 

Hi Richard

Thank you for that. I'll give it a try with my existing menu.

Catherine

 
Average of ratings: -
Picture of Catherine Berry
Re: Moodle 2.0: Custom menu in core
 

Hi Richard

I've made some progress with this. I took the original menu from the 1.9 Afterburner theme (with just the placeholders in, as I expect my actual menu will need a bit of rewriting for 2.0). It has an automatic My Courses bit, which caused some problems because it uses a deprecated function, so I've commented that out for now - I feel reasonably confident that I'll be able to fix it.

I included the menu in my layout file. The menu is appearing, but the drop-downs don't work. I expect something more is needed. Looking at the original header.html file from Afterburner 1.9, there is a load of stuff in there which I guess is making the menu work.

<script type="text/javascript" src="<?php echo $CFG->wwwroot ?>/lib/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="<?php echo $CFG->wwwroot ?>/lib/yui/container/container_core.js"></script>
<script type="text/javascript" src="<?php echo $CFG->wwwroot ?>/lib/yui/menu/menu.js"></script>
<script type="text/javascript">
YAHOO.util.Event.onContentReady("dropdown", function () {
var oMenuBar = new YAHOO.widget.MenuBar("dropdown", {
autosubmenudisplay: true,
hidedelay: 750,
lazyload: true });
oMenuBar.render();
});
</script>

I tried pasting this in, but it didn't work - I wasn't too surprised by this because the lib/yui folder doesn't seem to contain the same stuff as before. Can you tell me what I need to put in to make the menu work?

Many thanks

Catherine

 
Average of ratings: -
Picture of Richard Oelmann
Re: Moodle 2.0: Custom menu in core
Group Particularly helpful MoodlersGroup Testers

Hi Catherine,

I haven't actually tried this yet, but will have a go thisevening if you haven't already got it working, but, looking into the lib/yui folder in moodle 2 - and if my memory is correct 1.9 used the yui2.8 framework: the build of 2.0 I have has both the 2.8 and 3 frameworks available - then try altering the lib/yui references to /lib/yui/2.8.2/build/filename.js

<script type="text/javascript" src="<?php echo $CFG->wwwroot ?>/lib/yui/2.8.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="<?php echo $CFG->wwwroot ?>/lib/yui/2.8.2/build/container/container_core.js"></script>
<script type="text/javascript" src="<?php echo $CFG->wwwroot ?>/lib/yui/2.8.2/build/menu/menu.js"></script>

Hope that's useful and helps you make progress smile

Richard

 
Average of ratings:Useful (1)
Picture of Catherine Berry
Re: Moodle 2.0: Custom menu in core
 

Hi Richard

Thank you so much for the quick reply - it worked! big grin

Just need to get my actual menu items put in and get the styling done now.

Many thanks for your help.

Catherine

 
Average of ratings: -
Picture of Richard Oelmann
Re: Moodle 2.0: Custom menu in core
Group Particularly helpful MoodlersGroup Testers

Yippeee!!!

(need to pinch Mary's cheerleader smiley here big grin)

Glad you got it working Catherine. Hopefully most of the styling should be very similar/same as what you used in 1.9 so should prove fairly straightforward to adapt into your 2.0 version

Good work, glad to be of help

Richard

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Hi Catherine,

I'm only just getting into php coding but I did wonder if your ordering was the problem in this case...how about...

$branchlabel=$branchtitle;
$branchtitle = 'BBC website';
$branchurl = 'http://www.bbc.co.uk';
$branchsort = 3;

$branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort));

Mary

 
Average of ratings: -
Picture of Catherine Berry
Re: Moodle 2.0: Custom menu in core
 

Thank you for replying Mary. I don't think that's the problem though - I copied Sam's code for the My courses menu and just changed the variables. As I said, it works perfectly well if I'm using a moodle url - it just doesn't like an external one.

I think Richard's suggestion may be the way to go... but if anyone does know what I've done wrong, I'd be interested to know!

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Hi Catherine,

I've just been looking at that tutorial, and wondered why I never got it to work.

There is a mistake in the file name of this file

lang/en/themename.php

it should be

lang/en/theme_themename.php (where themename is the name of YOUR custom theme eg: theme_base.php (ref.1) from base theme)

(ref.1) Take a look at the lang/en/theme_base.php in base theme folder of your moodel site for reference how to add the strings.

In your theme_themename.php  you need to add the various strings which will be called by the renderers.php such as, in your case, branchlabel and branchurl.

$string['branchlabel'] = 'BBC Website';
$string['branchurl'] = 'http://www.bbc.co.uk';

Then your code in the renderers.php will look something like...

$branchlabel = get_string('branchlabel');
$branchurl   = get_string('branchurl');
$branchtitle = $branchlabel;
$branchsort  = 3;

etc...

HTH

Mary


 
Average of ratings: -
Picture of Catherine Berry
Re: Moodle 2.0: Custom menu in core
 

Hi Mary

I did have the correct filename for the language file. I've tried your suggestion but the result is the same. When I have $branchurl set to a moodle url, it works, and the menu item shows up with the correct label - so it's quite happy to have the strings defined directly.

My feeling is that it's something to do with the way the renderer processes the url that it usually gets from the custom menu, but I don't understand the process enough to be able to work it out - I'm fairly new to php. What puzzles me is that using a non-moodle url breaks the whole page, rather than just giving me a link in the menu that doesn't work - if it did that at least I'd have some idea what it had done to the url!

Thanks

Catherine

 
Average of ratings: -
Picture of Balram Pandey
Re: Moodle 2.0: Custom menu in core
 

I am new to moodle, Can anybody please help me to add custome tab in Moodle 2.1, just like Moodle.org, If i click on community tab it display, for example " http://moodle.org/community/", same thing If i click on froum "http://moodle.org/forums/ " I also want to make like that,  for my website, " http://www.powerenergyindia.com/moodle/" .

 

I want to make menu tab exactly which moodle.org has.

 

Thankx

Balram

 
Average of ratings: -
Picture of Richard Oelmann
Re: Moodle 2.0: Custom menu in core
Group Particularly helpful MoodlersGroup Testers

Balram,

Go to the Theme Settings page (Site Administration > Appearance > Theme Settings)

Near the bottom you will find the custom menu items with an example of how to structure the menus.

This will then add the menu automatically in every theme (at least I can't think of any that don't have it in somewhere) without needing to add any code anywhere.

Richard

 
Average of ratings: -
Picture of Balram Pandey
Re: Moodle 2.0: Custom menu in core
 

Thank you very much Richard, I tried this one and it's working really great. Thanks again.

I have another question is that, If i go to www.moodle.org site and I click on community tab moodle.org it display in URL something like this "http://moodle.org/community/" , "http://moodle.org/forums/". I mean to say my domain name and that tab name like community,forum etc, and it displays separate page and in that page I want to give some more stuff. Is this possible to do that in for my website? exactly same like moodle.org . You can check http://www.powerenergyindia.com/moodle/

I want to make something like this which moodle.org has this feature.

community|http://moodle.org/community
-Forums|http://moodle.org/forums

for my website

Contactus|http://powerenergyindia.com/contact    (in url    http://powerenergyindia.com/community/)

-Aboutus|http://powerenergyindia.com/Aboutus   (here it display separate page on that page I want to give my stuff.)



Thanks.

Balram

 
Average of ratings: -
Picture of Mahtab Bukhari
Re: Moodle 2.0: Custom menu in core
 

May you live in peace Mary!

 

I am having a little issue in custom menu. I want to open a link in new windows. I got your post and tried the following:

-CFR 47 FCC Telecom Rules|http://ecfr.gpoaccess.gov/cgi/t/text/text-idx?c=ecfr&tpl=/ecfrbrowse/Title47/47tab_02.tpl" target="new

But it did not work.  When I checked the url in status bar, I came to know that moodle is changing the url by adding / before each ". So, url becomes:

-CFR 47 FCC Telecom Rules|http://ecfr.gpoaccess.gov/cgi/t/text/text-idx?c=ecfr&tpl=/ecfrbrowse/Title47/47tab_02.tpl\" target=\"new

Any suggestion to avoide this automatic addition of \ in url?

Mahtab

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Hi,

That is because Moodle has moved on from the way the menu is written.

Try this ...

-CFR 47 FCC Telecom Rules|http://ecfr.gpoaccess.gov/cgi/t/text/text-idx?c=ecfr&tpl=/ecfrbrowse/Title47/47tab_02.tpl|CFR 47 FCC" target="_new|

The way the menu is now allows you to add a 'tooltip' which is writtn in the page source as (in this case) title="CFR 47 FCC" and then you need to add the target, so this you would do by adding the last " off the title and adding target="_new and leave off the last " as this will be added by Moodle.

I hope this explains it OK.

Also...and this may come in handy for you if you need to add language strings within your menu at some point in your job as webmaster.

Now you can do this in custommenu...

menu title | url | tooltip | lang

So in english we would use...

Dictionary|http://http://oxforddictionaries.com/|English|en

and in Arabic...

قاموس|http://www.lexilogos.com/english/arabic_dictionary.htm/|العربية|ar

You would need to add BOTH links in the Theme settings page, and then depending on your language choice selected in your Moodle site only the one relative to the language chosen would show in the menu bar.

HTH

Mary

 
Average of ratings: -
Picture of Mahtab Bukhari
Re: Moodle 2.0: Custom menu in core
 

May you live in peace Mary!

Thank you very much once again. May you live long with full health & wealth!

I have tried your suggestion but it does not appear to work. Whole text CFR 47 FCC" target="_new starts to apear at tool tip but the link does not open in new window.

If you do not have any further suggestion, kindly, at least, inform me where can I find the code which is dealing with this menu appearance, so I can play with it to try to do the needful.

Thank you very much once again for your detailed reply.

Have a good day.

Regards.

Mahtab

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Matab,

Unfortunately there is no way this will work now. The way it is configured appears to forbids any extra code to be entered.

Sorry

Mary

 
Average of ratings: -
Picture of Alessandra Zago Dahmer
Re: Moodle 2.0: Custom menu in core
 

Hello!
Please could you help me?
I would like to know how to change the menu for each course. (version of moodle: 2.0.3)
that is, on the front page I have a menu. But, I would like to modify this menu to the courses.
I've tried to do this procedure. but in all courses appears the same menu of the main page ...
thank you!

 
Average of ratings: -
Me
Re: Moodle 2.0: Custom menu in core
Group Moodle Course Creator Certificate holders

Hello Alessandra,

Have a look at this discussion here >> http://moodle.org/mod/forum/discuss.php?d=193738 Where a very similar question was asked.

I think the answer is that at the moment, if you put things in the custom menu, it is applied the same across the whole site. But there are alternatives, given in the thread that I linked above.

 
Average of ratings: -
Picture of Alessandra Zago Dahmer
Re: Moodle 2.0: Custom menu in core
 

Hello Miriam! thank you very much for the support.
1. I included the lines in moodle / theme / aardvarksetting.php:

$name = 'theme_afterburner/custommenuitems';
$title = get_string('custommenuitems', 'admin');
$description = get_string('configcustommenuitems', 'admin');
$default = '';
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$settings->add($setting);


2.included the line in moodle / theme / aardvark / layout / general.php (the aardvark theme uses the file general.php and does not use default.php) for this:

$custommenu = $OUTPUT->custom_menu($PAGE->theme->settings->custommenuitems);


3. I included the following lines below into moodle / / lib / outputrenderers.php

  public function custom_menu($custommenuitems = '') {
        global $CFG;
        if (empty($custommenuitems) && !empty($CFG->custommenuitems)) {
            $custommenuitems = $CFG->custommenuitems;
        }
        if (empty($custommenuitems)) {
            return '';
        }
        $custommenu = new custom_menu($custommenuitems, current_language());
        return $this->render_custom_menu($custommenu);
    }


with the operation above it was possible to visualize the field "custom menu items" in administration - theme settings.
I've included the menu items that I am customizing.

I finished the procedure excluding caches.
Howeverthe custom menu does not appear in the theme I'm using in the course.
Could you please help me? what went wrong in the operation?

regards!

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

This will not work in anything less then Moodle 2.3 and that version has not yet been released.

However to get this to work, you would need to change a Moodle CORE file.

This is the patch:

https://github.com/danmarsden/moodle/commit/0f6d934941b9ff21846ff8808b6d50be9df54eaf

Also, in your comment above I see you have made a mistake with the code...you need to rename this from afterburner to aardvark like this...

$name = 'theme_aardvark/custommenuitems';
$title = get_string('custommenuitems', 'admin');
$description = get_string('configcustommenuitems', 'admin');
$default = '';
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$settings->add($setting);

Hope this helps?

Mary


 
Average of ratings: -
Picture of Alessandra Zago Dahmer
Re: Moodle 2.0: Custom menu in core
 

Hi Mary,
thank you very much!

changed the code to:

$name = 'theme_aardvark/custommenuitems';
$title = get_string('custommenuitems', 'admin');
$description = get_string('configcustommenuitems', 'admin');
$default = '';
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$settings->add($setting);

However it did not work again.

Now I understood. I can´t customize the menu in the themes of the courses in version 2.0.8
The 2.X version of moodle is not appropriate for anyone working with customized courses ...
I'll have to go back to version 1.X. .. sad
moodle version 1.x I could customize the menu in the code in the aardvark_menu.php ... sad

Mary: thank you!

 
Average of ratings: -
Picture of Richard Oelmann
Re: Moodle 2.0: Custom menu in core
Group Particularly helpful MoodlersGroup Testers

Hi Alessandro,

While it is true that you cannot use the built in custom menu in Moodle 2.0.8 in this way (unless you implement the patch Mary has given the link to), the menu used in aardvark in 1.9 can be coded into the themes in Moodle2 in exactly the same way as it is used in 1.9, calling that menu instead of the Moodle2 custom menu (using a php include(aardvark_menu.php) command in its place). I have done this on occasion when I wanted to implement conditional menus (different menus for different groups of users)

So if you wish to move to Moodle2, the possible lack of certain features in the inbuilt custom menu should not hold you back.

Richard

 
Average of ratings: -
Picture of Alessandra Zago Dahmer
Re: Moodle 2.0: Custom menu in core
 

Hello Richard,
good news! thank you! smile
Please, could you comment how you did this procedure?
I'm having trouble doing this operation that you did ... sad
thank you very much!! 

 
Average of ratings: -
Picture of Richard Oelmann
Re: Moodle 2.0: Custom menu in core
Group Particularly helpful MoodlersGroup Testers

OK Alessandra smile

Firstly I am working on a menu requirement I've been asked for and have been playing with Daniel's Zebra theme do this - so the code snippet below is from there, but it should guide you in doing something similar in other themes.

<?php if ($hascustommenu) { ?>                      //Look for this section in the general.php (or any other layout file)
   <div id="custommenu-wrapper">
       <div id="custommenu"><a class="home" href="<?php echo new moodle_url('/index.php'); ?>"><div>&nbsp;</div></a><?php echo $custommenu; ?><a class="calendar" href="<?php echo new moodle_url('calendar/view.php'); ?>"><?php echo date("F j, Y"); ?></a></div>                            //This is the important bit to find in any other theme
   </div>
<?php } ?>
                    
<?php
if (isloggedin()){                                              //This section was added in to my code to select a categroy of user based on their email addresses within the university
    $useremail=$USER->email;
    //echo $useremail;
    $useremailtype=substr($useremail,-22,-14);
    //echo $useremailtype;
    if ($useremailtype=="students") {$usertype="student";
        }else{$usertype="staff";
        }
    //echo $usertype;
    }else {$usertype="student";
    }
?>
<div id="webteammenuwrapper"><?php include('menu'.$usertype.'.php');?></div>            //This is the important bit to add back in to replace the $custommenu - in my case it calls either menustaff.php or menustudent.php depending on the code above

To put it very simply - and not relate it to any particular theme, you need to replace the <?php echo $custommenu; ?> with <?php include('menu.php');?>

You then need to have a menu.php in your theme layout file and the css style sheet to give it the look and feel in your styles folder (if you are adding a new sheet rather than adding the rules to an existing sheet, don't forget to add it to the theme config.php as well). These could be the files you already have from the 1.9 theme you are using. In my case I also changed the div that wraps the menu to match the 1.9 version rather than the div that the custommenu was inside.

I hope that helps to start with Alessandra, as it is still something I am currently working on I don't have a completly finished neat 'how-to' for you, just my working notes as above. There may be a couple of things I've missed out, but I think I've covered it all so far.

Richard

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Hi Richard,

You forgot the menujs.php that adds the javascript!!!

Mary

 
Average of ratings: -
Picture of Richard Oelmann
Re: Moodle 2.0: Custom menu in core
Group Particularly helpful MoodlersGroup Testers

Hi Mary,

Thanks for that - where do I need to add that as I can't find it in the 1.9 themes I've taken the menu from (my old school one which was originally based on aardvark-lite/liteheaded) and I haven't added it to zebra where I'm playing with this and yet the menu seems to work fine.

Right - just found it in your aardvark_automenu one and now I remember using it before in 1.9 wink Doh! But - is it needed when adding this to a 2.x theme? Aren't these functions already called by the core in order for the custommenu to work anyway, so there would be no need to call them again? or is it because the aardvark-lite menu that mine was based on works differently to the original aardvark one? I'll do some more investigation/exploration - but not today, it's Easter!!! :D

Happy Easter Mary (and everyone)

God Bless

Rich

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Hi Richard,

Happy Easter to you too. I'm just killing time waiting for dinner to cook! ...bahh...bahhh...smile

I got the old menu to work really nicely in a Moodle 2.0 theme backend of 2010 using YUI2 CSS ... of course this has been depreciated in Moodle 2.1.x but even so I dare say you could try adding the relevant YUI 2 .js scripts in a themes javascript directory and then declared in the theme's config.php so that they are then called into the header of the page.

I just loved that YUI d/down menu, it worked so easily and was pretty consistent too in IE7 as far as I can recall. However, since IE7 is off the Moodle radar we don't need to worry about it, nor IE8 for that matter.

Cheers

Mary



 
Average of ratings: -
Picture of Richard Oelmann
Re: Moodle 2.0: Custom menu in core
Group Particularly helpful MoodlersGroup Testers

Hi Mary,

Hope your dinner was tasty big grin

Unfortunately I'm not that fortunate in work - we still have a large number of PCs awaiting upgrade to Win7 (or not capable of being upgraded because of the hardware) which means I need to support IE8, even if the core moodle doesn't directly - I even discovered last week that we still have some machines with IE7 on them. That's basically why I went with my old school menu from 1.9 when I was asked to implement conditional menus again, because I knew I had it working on IE7 originally thoughtful As I said, I haven't done anything to add any menu javascript, although once you mentioned it I did remember using it previously, but the menu does work - that said it is only a single drop down and not multilevels and I haven't yet got around to testing it anymore (but will do - for my own information more than what is needed for work!) - which  is why I was wondering if it working from the yui scripts that must be called for the custom menu anyway.

I'll have a play over the next couple of days when I'm not playing with flexi3, or packing the caravan, and let you know how I get on smile

Rich

 
Average of ratings: -
Picture of Bill Steele
Re: Moodle 2.0: Custom menu in core
 

Is there a way to add a target to the custom menu addresses?

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

No! sad

 
Average of ratings: -
Picture of Mindy Workman
Re: Moodle 2.0: Custom menu in core
 

Is there a way to make the custom menu only appear after login? Right now, it is available on the frontpage before login. I'm sure it's something simple I'm missing...

 
Average of ratings: -
Picture of Richard Oelmann
Re: Moodle 2.0: Custom menu in core
 
Average of ratings:Useful (2)
Picture of Vicki Dunnam
Moodle 2.0: Custom menu in core
 

I have added the custom menu using the Themes settings.  I would like the menus to show on the right side of the screen instead of the left side of the screen.  What is the code to display these on the right side.  smile 

 
Average of ratings: -
It's only an avatar...
Re: Moodle 2.0: Custom menu in core
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Try

 
Average of ratings: -