autonav block is puzzling me a bit

Permalink
I like to achieve a navigation with autonav that looks similar to the "sitemap" on the dashboard: items are sorted like in the sitemap, all levels are expanded. i am using c5 5.5.

There are however odd things I came across when i tried to configure the autonav block.

- why do i _have to_ set controller->orderBy? (that whole "joshua's sorting crap" section)
- why can't the default order of the items be the same as in the sitemap on the dashboard?
- why does controller->displaySubPages = "all" not actually display all pages but only the 1st level of the subpages?

I am confused and puzzled :-D

Seems like I have to rewrite bits of this controller to suit my rarther simple needs...hmmmm.

nerdess
 
NBardales replied on at Permalink Reply
NBardales
Why don't you just create a template for the autonav block?

By creating a template, you can still use the interface to add the block (which means you make sure ALL sublevels show). Plus, by adding some javascript (in the template) you could make your autonav just like the Sitemap in the dashboard...
andrew replied on at Permalink Best Answer Reply
andrew
You shouldn't have to rewrite the block controller class...just know what to set those various properties to.

1. In order to get the autonav to display like the dashboard sitemap, you should use $controller->orderBy = 'display_asc' . This basically tells the autonav that the sorting criteria it should is going to be the default display order in the sitemap. That means the order that gets set when items are dragged around in the dashboard sitemap.

2. There's no fancy reason for why it's not, in this case. It probably should be, yes.

3. This is probably more of a misnamed property than anything else. There are two properties that handle this stuff:

displaySubPages
displaySubPageLevels

displaySubPages actually handles the types of sub pages that will be displayed. You should set this to "all". You could also set it to relevant_breadcrumb to make a breadcrumb or relevant to do something else. These are weirdly named but I've tried to document them in a how-to I'll post at the end.

displaySubPageLevels actually tells the autonav block how many levels to display. Set this to "all" as well and you should recurse all the way down the tree and get exactly what you want.

I've documented this in a how-to awhile back because some of the concepts are, as you've seen, a little confusing:

http://andrewembler.com/posts/concrete5-primer-auto-nav-block/...

Hope this helps!
nerdess replied on at Permalink Reply
nerdess
Thanks so much! The "displaySubPages" / "displaySubPageLevels" got me confused. It was down to lack of documentation, what would help would be an overview of all available methods/properties in the header of the controller or a link in the controller to your documentation (this actually would be good for all blocks).

Here is my code in case someone needs sth similar:

$nav = BlockType::getByHandle('autonav'); 
$nav->controller->orderBy = 'display_asc';
$nav->controller->displaySubPages = 'all';
$nav->controller->displaySubPageLevels = 'all';
$nav->render('view');
captadamhauck replied on at Permalink Reply
Hmm, when I tried to use the auto-nav, nothing showed up. I used it to try to list the pages under a certain page, but nothing shows.
http://www.captadamhauck.com, go to 'Shop'. On the right sidebar it should have an auto-nav list of the pages under that page. There should be "Backpacks","Duffel Bags","Electronics","Accessories". But I see nothing there, just the search. If I search for any one of the sub pages it shows and I can click on it and go to it, but still no page list in the auto nav (I put an auto-nav block on the top of the right sidebar in every page under 'Shop', including on the 'Shop' page). Did I misinterpret one of the options? Thought I tried it all...