Hide CSS drop-down menu until logged in

Hide CSS drop-down menu until logged in

by Mike Forshaw -
Number of replies: 5
Hi,

I was wondering if anyone knew a quick way to hide a CSS based drop-down menu until users have logged onto Moodle. The menu in question is at the top of the site. The site is http://www.cardinal-heenan.org.uk/moodle.

Kind regards,

Mike
Average of ratings: -
In reply to Mike Forshaw

Re: Hide CSS drop-down menu until logged in

by Frank Ralf -
Hi Mike,

the following CSS should hide the whole menu bar on pages shown for not logged in users:

body.notloggedin div.menubar {
display: none;
}

Note that the HTML is still there "under the hood". If you want the menu not to be served to the browser in the first place you might to have to tweak the PHP which outputs the menu.

hth
Frank
Average of ratings: Useful (1)
In reply to Frank Ralf

Re: Hide CSS drop-down menu until logged in

by Mike Forshaw -
Superb.

Cheers!
In reply to Mike Forshaw

Re: Hide CSS drop-down menu ITEMS based on role

by Gary Barclay -

Hi,

As a possible extension of this query is it possible to omit certain items from the drop downs based on the role of the user logged in. I.E. a teacher can see more options in a particular drop down than a student.

Could a solution to this be having 2 seperate menubars rather than omitting items from one single menubar.

Thanks,

Gary

In reply to Gary Barclay

Re: Hide CSS drop-down menu ITEMS based on role

by Frank Ralf -
Hi Gary,

Please open a new thread for this different question.

tia
Frank
In reply to Gary Barclay

Re: Hide CSS drop-down menu ITEMS based on role

by Mauno Korpelainen -
You can use different code from different files - create for example files teachers.php and students.php to "yourtheme" folder and add to header.html, meta.php or footer.html something like

<?php
if (!empty($USER->id)) { if (!empty($COURSE->id) and has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {include_once($CFG->dirroot .'/theme/yourtheme/teachers.php');} else {include_once($CFG->dirroot .'/theme/yourtheme/students.php');}} ?>

People who have capability to manage files are usually teachers or administrators and the code will load a different menu code for them from teachers.php while students will get menu from students.php

Or you can as well separate your current code with different capability checks (roles)
Average of ratings: Useful (1)