Themes

Boost theme - how to hide sidebar by default?

 
Picture of Chye Siaw
Boost theme - how to hide sidebar by default?
 

Moodle 3.2.1+

Hi, we are using the Boost theme on our Moodle website. It seems that the sidebar (containing navigation block) is open/closed depending on the user's last visit (ie if he left it open, next time he visits it remains open; vice versa).

Is there a way to hide the sidebar by default (every time the user visits the website), and only open when the button is clicked on?

This is to standardised everyone's view and also utilise the screen-width maximally.

Thanks in advance.


Edit: If you can point out where in the code we need to change that will be great.

 
Average of ratings: -
Picture of Dave Catlin
Re: Boost theme - how to hide sidebar by default?
 

I am not using the Boost theme, but I have the same issue.

 
Average of ratings: -
Gareth J Barnard
Re: Boost theme - how to hide sidebar by default?
Core developersParticularly helpful MoodlersPlugin developers

Hi Dave,

Silly question, but when the post refers to a piece of functionality that is only in the Boost theme then how can you have the same issue in another theme?

Kind regards,

Gareth

 
Average of ratings: -
Picture of Dave Catlin
Re: Boost theme - how to hide sidebar by default?
 

Its not an issue with the theme.  I don't want to open a page with the sidebar open.

 
Average of ratings: -
Picture of Chye Siaw
Re: Boost theme - how to hide sidebar by default?
 

The sidebar is dictated by the theme.

What theme are you using?


Anyway, I figured out where to alter the code in Boost:

Line 31-34 in theme/boost/layout/columns2.php

Change

if (isloggedin()) {

    $navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true');

} else {

    $navdraweropen = false;

}


To


if (isloggedin()) {

    $navdraweropen = false;

} else {

    $navdraweropen = false;

}


This will result in the sidebar being always closed on revisit regardless of its previous state that the user left it as.

 
Average of ratings: Useful (3)
Picture of Vladimir Gomez
Re: Boost theme - how to hide sidebar by default?
 

Hello Chye Siaw, everyone.

This worked for me with the side effect that it always closes the sidebar when changing pages (I wanted it to stay open if the user opened it to go to another section). To solve it, I added a variable to the session and tested for it on the if. This is the code:

if (isloggedin() && isset($_SESSION['alreadyloggedin'])) {
    $navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true');
} else {
    $navdraweropen = false;
    $_SESSION['alreadyloggedin'] = true;
}
Hope it helps somebodoy.

Regards,

Vlad.

Edit:
A slightly more efficient version of this code would be:


if (isset($_SESSION['alreadyloggedin'])) {
    if (isloggedin()) {
        $navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true');
    } else {
        $navdraweropen = false;
    }
} else {
    $navdraweropen = false;
    $_SESSION['alreadyloggedin'] = true;
}

 
Average of ratings: -