Hi everyone,
I want to hide the whole navigation block from some roles(not admin) while keep some other blocks, such as calendar and custom block. Is there a way to do it? Thanks.
maybe you can check if the user is an admin and add a style tag to the header that sets the display to none for all blocks an admin doesn't need to see?
* turn on the editing on the front page and then click the edit icon of
the navigation block
* Ignore the central settings and look down to the left - there is a
settings block for the navigation block *Click the blue "permissions"
link
*In the line "view block" click the X of those you don't want to view the block. (if you are doing this on the front page you would need to use authenticated user as normally you won't have teachers/students assigned on the front page)
* If you do change your mind, click the + and it will offer roles for
you to give back the viewblock permission to/
Sorry, you have to do the permissions on EVERY single page, if any other teacher add any new page, the nav block will reveal to all users.
I really dislike the new Nav block in Moodle2.0. Because my courses are designed for different groups. I don't want them to know each other. But, the Nav block just show every courses available on my site.
To totally hide the Nav block, Site Administration > Plugins > Blocks > Manage blocks > Navigation=OFF.
By doing this, Admin has to go: Site Administration > Courses to find the whole course list.
Thanks for all the replies.
I came up with an solution(kind of) like this:
The theme I use have two sidebars defined but I show them on the side area, side-pre and side post. I put all blocks I want to show to everyone in side-pre, while showing those just for admin in side-post. Then in the theme layout, I use is_siteadmin to check if it is admin, show both side area; if not, just show side-pre.
Hope this help. Thanks for sharing your ideas.
Hi, we have done this in our custom theme. It's quite easy. Although the original poster found an alternate workaround I thought it might still be useful to give the 'correct' answer for if you really want to do exactly what was requested.
Here is a function from our theme_ou_core_renderer class which extends core_renderer (I am not going to explain how to override renderers here, you will need to read the documentation such as it is, or look at full code - unfortunately full code of our own theme is not public at the moment.)
As you can see this is more complicated than the requirements here; we hide the Settings block, except when looking at pages with the 'mydashboard' page layout, and except for people with a certain (new) capability. You could change this to hide it always and to use issiteadmin instead of checking capability (and obviously change the block).
Note: I didn't write this code, just pasting it here
--sam
/**
* Override the block function to hide setting block when logged in as student.
* @param block_contents $bc HTML for the content
* @param string $region the region the block is appearing in.
* @return string the HTML to be output.
*/
public function block(block_contents $bc, $region) {
global $COURSE, $PAGE;
//Hide the Setting blocks when logged in as student.
if (isset($bc->attributes['class']) &&
strpos($bc->attributes['class'], 'block_settings') !== false) {
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
if (!has_capability('theme/ou:viewextrablock', $context)) {
// Show if student is viewing user profile related pages
if ($PAGE->pagelayout !== 'mydashboard') {
return '';
}
}
}
return parent::block($bc, $region);
}