[LearnR] Site home to display the block drawer by default

[LearnR] Site home to display the block drawer by default

by Visvanath Ratnaweera -
Number of replies: 2
Picture of Particularly helpful Moodlers Picture of Translators
Moodle 4.1, LearnR v4.2.r8 (2023071008) Currently the home page of the site is shown to the visitor (not logged in) with the block drawer closed - only an arrow to open it. How can I make it to be open by default?
Average of ratings: -
In reply to Visvanath Ratnaweera

Re: [LearnR] Site home to display the block drawer by default

by Bob Gilmore -
Picture of Particularly helpful Moodlers
Hey Visvanath. This problem isn't just a LearnR theme problem, but one for any boost based theme.

There are a couple of fixes that work. My preferred one is to use the Admin > Appearance > Additional HTML > Within Head:

<script>
window.addEventListener('load', () => {
   if( window.matchMedia('(min-width: 700px)') ) {
document.querySelector('#page-site-index .drawer-right-toggle button').click();
} });
</script>

This forces the block drawer open on the site index only and only if the page is greater than 700px wide.  For every page on the site, remove #page-site-index from the query selector.

If you feel comfortable building a child theme or even hacking the boost code, this tracker item https://tracker.moodle.org/browse/MDL-75303 has a means of modifying the code to achieve the same result.



Average of ratings: Useful (1)
In reply to Bob Gilmore

Re: [LearnR] Site home to display the block drawer by default

by Yvan Leduc -

Thank you Bob for this contribution.  I remove, as you suggested, the  #page-site-index to show the block on every pages.

The consequence is that when the user logs in, the block drawer effectivly shows but when he goes to an other page, the drawer closes.

The code is doing a toggle between the states open and close. 

How to modify this code to keep th drawer open ?

Thanks

Yvan