RESOLVED | Essential theme:Can I hide custom menu before login?

RESOLVED | Essential theme:Can I hide custom menu before login?

by Nyree Williams -
Number of replies: 17

Hello Julian/ anyone using a Bootsratp theme

Is it possible to hide the custom menu before login in your theme? If so how?

I've tried previous suggestions but they don't seem to work in Bootstrap,

Many thanks

Nyree

(Edited by Mary Evans - original submission Thursday, 19 September 2013, 3:52 PM) Added Essential theme to subject line to enable search bots to find it.

(Edited by Mary Evans - original submission Friday, 20 September 2013, 1:04 PM)

Average of ratings: -
In reply to Nyree Williams

Re: Can I hide custom menu before login?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Nyree,

First look in your 'config.php' file of the theme you are using to see what layout file is for the 'frontpage' (if none listed look in 'bootstrapbase/config.php'):

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

That tells us to edit 'columns3.php' so go to the 'layout' folder of the theme (even if you looked in 'bootstrapbase/config.php').  Then find the line containing (around no. 46):

and change it to:

No need to 'Purge all caches'. 

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Can I hide custom menu before login?

by Nyree Williams -

Hello Gareth

I've found this:

$custommenu = $OUTPUT->custom_menu();
$hascustommenu = (empty($PAGE->layout_options['nocustommenu']) && !empty($custommenu));

not quite the same - which bit should I change?

Thanks

Nyree

In reply to Nyree Williams

Re: Can I hide custom menu before login?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Nyree,

Neither.  You need to find the code that does something like:

echo $custommenu

and change it to:

if (isloggedin()) { echo $custommenu; }

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Can I hide custom menu before login?

by Nyree Williams -

Hello Gareth

I've found this:

$custommenu = $OUTPUT->custom_menu();
$hascustommenu = (empty($PAGE->layout_options['nocustommenu']) && !empty($custommenu));

not quite the same - which bit should I change?

Thanks

Nyree

In reply to Nyree Williams

Re: Can I hide custom menu before login?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Nyree,

As I said earlier "Neither" smile. You need to find the code that does something like:

echo $custommenu

and change it to:

if (isloggedin()) { echo $custommenu; }

Cheers,

Gareth

In reply to Nyree Williams

Re: Can I hide custom menu before login?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Nyree,

Assuming you are using a copy of Clean theme, then the code you should be looking for in layout/columns3.php (the green highlighted section is what makes the menu display only after login...

<header role="banner" class="navbar navbar-fixed-top<?php echo $html->navbarclass ?>">
    <nav role="navigation" class="navbar-inner">
        <div class="container-fluid">
            <a class="brand" href="<?php echo $CFG->wwwroot;?>"><?php echo $SITE->shortname; ?></a>
            <a class="btn btn-navbar" data-toggle="workaround-collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>
            <div class="nav-collapse collapse">

                <?php 
           if (isloggedin) {
               echo $OUTPUT->custom_menu();
           }  ?>
                <ul class="nav pull-right">
                    <li><?php echo $OUTPUT->page_heading_menu(); ?></li>
                    <li class="navbar-text"><?php echo $OUTPUT->login_info() ?></li>
                </ul>
            </div>
        </div>
    </nav>
</header>

Hope this helps?

Cheers

Mary

In reply to Mary Evans

Re: Can I hide custom menu before login?

by Nyree Williams -

Hello Mary

I'm using Julian's Essential theme

I've replaced the string in the columns3.php (in Bootstrap base and Clean) and in other php files in the Essential theme; I've managed to remove the menu from the login page but not the front page (the string didn't appear in the frontpage.php file as I would have expected)

Any suggestions?

Thanks

Nyree

In reply to Nyree Williams

Re: Can I hide custom menu before login?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Nyree,

Ok, I did not realise you were using the Essential theme, so edit 'layout/frontpage.php' around line 161 and change:

to:

Cheers,

Gareth

Average of ratings: Useful (1)
In reply to Gareth J Barnard

Re: Can I hide custom menu before login?

by Giampaolo Mangiaracina -

I made Gareth changes but partially works: custom menu is hided from first page (home-pre-login) but appears in login page (just after user clicks on login button)... is possible to show custom menu AFTER login is completed?

In reply to Giampaolo Mangiaracina

Re: Can I hide custom menu before login?

by Julian Ridden -
You will need to repeat the steps in layout/login.php In fact, to have best results throughout the site you probably want to do the same thing in all the layouts. Julian
Average of ratings: Useful (1)
In reply to Julian Ridden

Re: Can I hide custom menu before login?

by Philip Roy -

Sorry, I know this thread is a little dated and the code for the Essential theme has moved on...but I can't find the relevant code in the latest version (2.7.6b) in Moodle 2.7


Would love to see this as an option within the theme rather than needing to hack code.


Cheers,


Phil

In reply to Philip Roy

Re: Can I hide custom menu before login?

by Philip Roy -
Found the answer...as per the second posting instructions, but the file to edit is now....

/layout/includes/header.php at around line 145

Phil


In reply to Philip Roy

Re: Can I hide custom menu before login?

by Jérôme DEMIAUX -

You can get same result without touching the code, simply by playing with CSS sheets by adding 

#page-login-index #custom_menu, #page-site-index.notloggedin #custom_menu {display:none;}

Update and maintenance should be easier.

Jérôme.

Average of ratings: Useful (1)
In reply to Philip Roy

Re: Can I hide custom menu before login?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

If you want it as an option, please raise an enhancement issue on the themes GutHub issues.

In reply to Gareth J Barnard

Re: Can I hide custom menu before login?

by Philip Roy -

OK, so I know this is getting a bit complex...but how would I code it that the menu is hidden to users who are not logged in and also hidden to logged in guests? We're contemplating having some Help pages publicly accessible (done so using guest auto login to this as a course), but I don't want the custom menus to be accessible to anyone until they authenticate as a student or staff member.


Phil

In reply to Philip Roy

Re: Can I hide custom menu before login?

by Philip Roy -

OK got it figured....

                            <div id="custom_menu">
                                <?php if (isloggedin() && !isguestuser()) {echo $OUTPUT->custom_menu();} ?>
                            </div>


Phil