Autonav display by attribute 5.6.0+
Permalink 1 user found helpful
I have been building a c5 site since 5.5.2.1 and am attempting to do a clean upgrade to 5.6.0.2
Currently I am attempting to update the very messy autonav templates to the new MUCH cleaner format. A core feature I had added was the ability to have different templates displaying only pages with a specific attribute. This was accomplished in the old template with the following code:
The error that occurs:
I have tried using the same method with no success under the new template. Any assistance would be greatly appreciated.
Currently I am attempting to update the very messy autonav templates to the new MUCH cleaner format. A core feature I had added was the ability to have different templates displaying only pages with a specific attribute. This was accomplished in the old template with the following code:
$aBlocks = $controller->generateNav(); foreach($aBlocks as $ni) { $_c = $ni->getCollectionObject(); if ($_c->getCollectionAttributeValue('include_header_nav')) {
The error that occurs:
Fatal error: Call to undefined method stdClass::getCollectionObject() in /home/alivetest/test4/blocks/autonav/templates/header_nav.php on line 9
I have tried using the same method with no success under the new template. Any assistance would be greatly appreciated.
thanks this is very helpful. for a designer its hard to figure out the auto nav when the code has changed in latest c5 :)
its the little snippets of code that make the difference.
i do like how clean the auto nav code is now in latest c5
its the little snippets of code that make the difference.
i do like how clean the auto nav code is now in latest c5
this is my attempt at getting a auto nav to show a top level page and its children. great for side panel navs when your client askes to only include certain pages on the side panel.
you only need to add the attribute to the top level page and it will know to keep looping to finish the drop down. take a look at this side nav on the last site i made http://www.showyourmussel.co.uk/join/visitor/...
foreach ($navItems as $ni) { $loop = 0; $_c = $ni->cObj; if ($_c->getCollectionAttributeValue('include_in_gallery_side_nav')) { $i = 1; $loop = 1; } else if ($i == 1 && $ni->level != 1) { $loop = 1; } else if ($i == 1 && $ni->level == 1) { $i = 0; // $loop = 1; } if ($loop == 1) {
Viewing 15 lines of 25 lines. View entire code block.
you only need to add the attribute to the top level page and it will know to keep looping to finish the drop down. take a look at this side nav on the last site i made http://www.showyourmussel.co.uk/join/visitor/...
You're welcome, sorry again about the variable.
edit: Sorry to anyone who copied this code before 2013.10.15, the variable $obj clashed with the one in block_view_template.