Accordion Menus in Books or Course Format? Yui? CSS? Ideas?

Accordion Menus in Books or Course Format? Yui? CSS? Ideas?

by Brian Merritt -
Number of replies: 3
Picture of Particularly helpful Moodlers

I am building an accordion menu for a course format that takes the Moodle Book Table of Contents and turns off sub chapters unless the student has clicked on the main chapter above those sub chapters.

If anyone has already done this, I would appreciate suggestions.

I have had a look at the Admin & Navigation blocks, but the Yui javascript code is massive overkill and also designed for block menus.  

I don't mind modifying the code in Books (will create a new resource) or Course Format, but the question is how to implement a simple accordion in the menu?  Examples appreciated smile

Average of ratings: -
In reply to Brian Merritt

Re: Accordion Menus in Books or Course Format? Yui? CSS? Ideas?

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

Hi Brian,

A search gives this: http://jafl.github.io/yui-modules/accordion-horiz-vert/.  If you want to look at how you build a YUI module into a format then look the the Grid format which captures keyboard events using a custom gallery module.

Or look at jQuery solutions and follow the Moodle docs for using in a module.

You say you are creating a course format, but they only manipulate the structure of the course but not the modules contained within.  When you look at a book for example, the course format is not even loaded.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Accordion Menus in Books or Course Format? Yui? CSS? Ideas?

by Brian Merritt -
Picture of Particularly helpful Moodlers

Hi Gareth

Thanks for coming back.  I am debating adding a new vertical column for the course format (yes, it would be theme dependent), so in effect I could hide the block module controls with CSS and then render something better/different without having to touch core.

I will try to decode what yui documentation exists one day, but I couldn't find enough of a clue as to the HTML layout and css classes to make a go of that accordion so I am implementing jquery as there are just 1,000s of times of more jsfiddles and the like.

The good news is I managed to combine responsive video with a (currently modified table of contents) book format that gives me the accordion table of contents, and will try to move this into the course format when I get a chance.

 

All the best


Brian

 

In reply to Brian Merritt

Re: Accordion Menus in Books or Course Format? Yui? CSS? Ideas?

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

Hi Brian,

No worries.

If you are going to use jQuery, then read http://docs.moodle.org/dev/jQuery.  I've not used jQuery in a theme in this way before, but in theory the $PAGE->requires should work and prevent clashes with anything else.

Cheers,

Gareth