Themes

sidebar in frontpage only for admin

sidebar in frontpage only for admin

Hi,

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: -
Re: sidebar in frontpage only for admin

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

'frontpage' => array(
'file' => 'frontpage.php',
'regions' => array('side-post'),
'defaultregion' => 'side-post',
),

Average of ratings: -
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: -
Re: sidebar in frontpage only for admin

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 - http://docs.moodle.org/22/en/my/index - 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.

Cheers,

Gareth

Average of ratings: -