Picture of Rich Dunn
Expanding menu
by Rich Dunn - Monday, 25 September 2017, 10:16 PM
 

Hi,

I'm a newbie, trying to get a handle on the framework and how we'd use it with our courses.  

I've been playing around and successfully created a sub menu but it isn't exactly what I'd like.  I'd like to have a main menu with menu items that expand when clicked, exposing the sub menu items, where each is clickable and would navigate to the appropriate content page.  Something like this:

Main Menu
|_Introduction (goes to content page)
|_Module 1 (expands when clicked)
  |_Lesson 1 (goes to content page)
  ...
  |_Lesson n (goes to content page)
...
|_ Assessment (goes to assessment or maybe just some final content page)

It looks like in order to do this, I'd need to create a new custom menu plugin and figure out how the NavigationView works and then possibly alter it at the core.  I obviously don't want to do that.  Am I over looking how the framework could work to accomplish this?  Any advice is appreciated.  

Thank you.

Rich

 

Picture of Matt Leathes
Re: Expanding menu
by Matt Leathes - Tuesday, 26 September 2017, 9:51 AM
 

Not sure, depends why you think you need to alter NavigationView...?

Picture of Stu Pod
Re: Expanding menu
by Stu Pod - Monday, 26 February 2018, 11:54 PM
 

Hi Rich,

That's exactly what I wanted to do and I had a just build an extension (plugin) myself. The trickiest bit was finding a reliable way to create a hierarchical representation of the course structure (including _type, displayTitle, _id, and _parentId).

I think Adapt.contentObjects.models[0].getAncestorModels()[0].attributes._children._byId was the only way I could find which was in the correct order.

I'd contribute my plugin, but it's very rough!

It does seem very odd that the AT encourages structuring a course with a hierarchical/tree structure using the 'Add sub menu' button, but the exported course (and the available plugins) don't seem to provide any way to navigate it using that same structure.

Picture of Matt Leathes
Re: Expanding menu
by Matt Leathes - Tuesday, 27 February 2018, 9:54 AM
 
I think Adapt.contentObjects.models[0].getAncestorModels()[0].attributes._children._byId was the only way I could find which was in the correct order.

You can get the same data via the much shorter piece of code:

Adapt.contentObjects._byId

The whole ethos behind Adapt is that it's there for you to be able to extend as you need...

 

Picture of Stu Pod
Re: Expanding menu
by Stu Pod - Thursday, 1 March 2018, 1:46 AM
 

Hi Matt,

It looks like I tried that before, and I just tried it again. Adapt.contentObjects._byId seems to return things in the wrong order.

I don't remember every detail because it was the middle of last year when I last looked at it in depth but I seem to remember that contentObjects.json itself stores them in the same wrong order.

I remember trying to work out which part of the AT code parses it and displays it in the right order in the AT menu editor so that I could use similar logic to get Adapt.contentObjects._byId in the right order, but I couldn't find anything.

I also wrote my own version of https://github.com/cgkineo/adapt-quicknav/ because of the same issues.

Picture of Matt Leathes
Re: Expanding menu
by Matt Leathes - Thursday, 1 March 2018, 11:43 AM
 

Hi Stu

Not sure how that's happening then because Adapt.contentObjects.models[0].getAncestorModels()[0].attributes._children._byId looks to me like it's just a much longer way of stating the same thing, equivalent to saying 'give me an ordered list of my eldest son's parents' children'...

Note that _byId is private property of Backbone so it's not really intended to be accessed directly like that. Adapt.contentObjects will give you a Backbone Collection that you can iterate through, equally Adapt.contentObjects._byAdaptID might be a better way.

It may be down to how the AT automatically generates and assigns IDs to contentObjects/articles/blocks/components - I do most of my work in the Framework so am used to being able to set these up for myself.