Autonav displayPagesCID = '92' not working when on page 92

Permalink
Hi There,

I'm trying to create a section sub nav using the following:
<?php 
$bt_main = BlockType::getByHandle('autonav'); 
$bt_main->controller->displayPages = 'custom';
$bt_main->controller->displayPagesCID = '92';
$bt_main->controller->orderBy = 'display_asc'; 
$bt_main->render('templates/sub_nav');
?>



This works great when on the children of the parent but when viewing the parent page, I see the top level pages instead of the children of page 92.

Sorry of this is easy but just can't seem to work this out - any help would be much appreciated.

Cheers

Ben

 
jordanlev replied on at Permalink Reply
jordanlev
Hmm... that looks like it should work. Try adding these settings as well:
$bt_main->controller->displaySubPages = 'all';
$bt_main->controller->displaySubPageLevels = 'all';
cmscss replied on at Permalink Reply
Thanks for that but now when on the parent page, it displays every page in the site!

Is my custom template code stuffing things up maybe?

<?php 
   defined('C5_EXECUTE') or die("Access Denied.");
   $bt->controller->displayPages = 'current';
   $aBlocks = $controller->generateNav();
   $c = Page::getCurrentPage();
   $nh = Loader::helper('navigation');
   $isFirst = true;
   foreach($aBlocks as $ni) {
      $_c = $ni->getCollectionObject();
      if (!$_c->getCollectionAttributeValue('exclude_nav')) {
         $target = $ni->getTarget();
         if ($target != '') {
            $target = 'target="' . $target . '"';
         }
         if ($ni->isActive($c) || strpos($c->getCollectionPath(), $_c->getCollectionPath()) === 0) {
jordanlev replied on at Permalink Reply
jordanlev
Hmm... well those autonav settings are always very confusing to me. What I usually wind up doing is putting an actual autonav block on my site, figuring out what settings to use in the block edit dialog for it (usually a trial and error process), then once I have it working properly I go back to the block edit and use Firebug to inspect each of the dropdown menus to see what the value of each selection is -- then I plug those into the template code.

If that's not something you're able to do, try searching around the forums for posts about which autonav variables are available and what each of them does -- I vaguely remember seeing something a while back where someone posted all of the various options and what they mean.
cmscss replied on at Permalink Reply
Well I'm glad you don't get them because I've been trying on and off for over 3 weeks!

I think I'll do it from the front-end.

Cheers

Mate...
jordanlev replied on at Permalink Reply
jordanlev
It took me 6 months to figure it out (and required a walkthrough from Andrew himself before I truly got it). And now I realize that I lost that knowledge somewhere on the way. So all I can offer now is moral support :)