Text field in custom autonav block for displayPagesCID

Permalink
I'm trying a bit of a hack to overcome an issue with the autonav when creating a stand alone tertiary (3rd level) nav but not sure if it is possible.

I've created a custom autonav and inserted it into a custom block. I have a text field in the block for page CID.

My custom autonav looks like this:

<?php   defined('C5_EXECUTE') or die("Access Denied."); ?>
<?php
$nav = BlockType::getByHandle('autonav');
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'custom';
$nav->controller->displayPagesCID = '135';
$nav->controller->displaySubPages = 'all';
$nav->controller->displaySubPageLevels = 'all';
$nav->render('tertiary');
?>


The code for the text field looks like this:
<?php  if (!empty($field_4_textbox_text)): ?>
<?php  echo htmlentities($field_4_textbox_text, ENT_QUOTES, APP_CHARSET); ?>
<?php  endif; ?>


Is there a way to insert this text field into this line of the autonav:

$nav->controller->displayPagesCID = '135';


So instead of 135 being hard coded, the user selects CID. This doesn't work, but something like:

$nav->controller->displayPagesCID = 'echo $field_4_textbox_text';


The gist of this is I want the user to be able to select the sub-nav they want which will include only the parent item and all the children. The difficulty with just using a normal autonav is that you need different nav setting for the parent and children. Any pointers on how to get the CID written out to the CID line in the autonav?

 
hollyb replied on at Permalink Best Answer Reply
I figured it it out. Needed double quotes like this: "$field_4_textbox_text";