sidebar in frontpage only for admin

Picture of edu g
sidebar in frontpage only for admin


I created a theme. I disabled the sidebar in the frontpage (deleted the line that shows it). however, the admin user should see it.

is there any way to do that? I was thinking about if (currentrole == admin) in the template but I can't see where  I can pull this information from.

i'm using moodle 2.2.6

Average of ratings: -
It's only an avatar...
Re: sidebar in frontpage only for admin
Core developersDocumentation writersParticularly helpful MoodlersPlugin developersTesters

You should NOT delete code you know nothing about, as it casues the problems you are seeing now.

Can I ask why you deleted the code?  If it was you only wanted the righthand side blocks to be on the fron page then you should delete the BLOCKS not the code!  Add all the blocks you wan visible on the front page and make sure they are on the side that you want them to be. I am assuming on the right as normally Admin pages use the Left side only.

Another way it to force Frontpage to only use one side block. You do this by changing this line in the theme's config.php

    // The site home page.
    'frontpage' => array(
        'file' => 'frontpage.php',
        'regions' => array('side-post'),
        'defaultregion' => 'side-post',

Average of ratings: -
Picture of edu g
Re: sidebar in frontpage only for admin

well, I'm  a software engineer and, despite the fact that I'm learning Moodle, I have basic skills and it made sense to me. I deleted it because I did not want any block at all in the front page. I tried removing the blocks using the browser but there was no way to get rid of the Settings block.

I just want a list of courses in the front page for all my students. If the admin sees a side bar with all the blocks it won't cause any harm, though.

What should be the correct way to achieve that?

Average of ratings: -
Gareth J Barnard
Re: sidebar in frontpage only for admin
Core developersParticularly helpful MoodlersPlugin developers

Dear edu g,

Mary is correct in saying about deleting code as that will only lead to maintainability issues - there are far better less sledge hammer solutions to this:

1. Use and set the 'My Moodle' page for users - - no code changes needed.

2. There is a function 'is_siteadmin()' with the $USER global - e.g. if (is_siteadmin($USER)) - I believe that it is not totally recommended and may not be supported in future, but it currently exists.  It does have a replacement but I'd have to look that up.  However, this should get you going.



Average of ratings: -