Hard-Coding Nav Block?
Permalink 4 users found helpful
I was wondering if I could lock down all instances of Auto Nav when in edit mode.
The only way I could figure out how to add Auto Nav areas was to create page types with Editable Areas and then stick in an Auto Nav block and apply it to all Children of that page type. So, now whenever I'm in Edit mode there's a whole bunch of outlines all over the place because I have a multiple nav scheme: one nav on the top, one on the left and 1 or 2 on the bottom depending on page.
All these dotted lines/Editable Areas are really senseless because the client would never edit these items. It just looks like a confusing mess.
The only way I could figure out how to add Auto Nav areas was to create page types with Editable Areas and then stick in an Auto Nav block and apply it to all Children of that page type. So, now whenever I'm in Edit mode there's a whole bunch of outlines all over the place because I have a multiple nav scheme: one nav on the top, one on the left and 1 or 2 on the bottom depending on page.
All these dotted lines/Editable Areas are really senseless because the client would never edit these items. It just looks like a confusing mess.
Thanks! You just wrap those 2 lines in between some php tags like this...
<?php
$b = Block::getByName('My Nav Menu');
if( is_object($b) ) $b->display();
?>
...where you want it to appear in your template?
<?php
$b = Block::getByName('My Nav Menu');
if( is_object($b) ) $b->display();
?>
...where you want it to appear in your template?
Exactly. I neglected to put in the php tags.
-Steve
-Steve
Hi Steve
I have made several attempts to hardcode my Nav block into my template using this technique but nothing appears on the web page. Here is the code I'm using:
I have copied the original block to the global scrapbook and it is correctly named. I have tried copying it to other scrapbooks to see if this works but it doesn't. I'm stumped. Can you think of any reason for this problem?
Many thanks,
Oliver
I have made several attempts to hardcode my Nav block into my template using this technique but nothing appears on the web page. Here is the code I'm using:
<?php $b = Block::getByName('Accordion Menu'); if( is_object($b) ) $b->display(); ?>
I have copied the original block to the global scrapbook and it is correctly named. I have tried copying it to other scrapbooks to see if this works but it doesn't. I'm stumped. Can you think of any reason for this problem?
Many thanks,
Oliver
I really like this Solution, but I am finding that using this method means that my Style Sheet is not being implemented.
I have to embed the contents either into my main style or directly into the templates view.php
Does anyone know how to get the style sheet to load using the Block:: method?
Do I need to include the Style as a addToHeader??
I have to embed the contents either into my main style or directly into the templates view.php
Does anyone know how to get the style sheet to load using the Block:: method?
Do I need to include the Style as a addToHeader??
Another way to do this is to use Advanced Permissions, then lock down edit access to what ever areas of your template you don't want your clients able to edit. You will of course need to create a separate login for them which you should be doing anyways.
This allows you to maintain full use of the c5 editing capabilities.
Just add;
define('PERMISSIONS_MODEL', 'advanced');
To your site.php file then you will notice you have a lot more flexibility with permissions on your site.
This allows you to maintain full use of the c5 editing capabilities.
Just add;
define('PERMISSIONS_MODEL', 'advanced');
To your site.php file then you will notice you have a lot more flexibility with permissions on your site.
I seem to like coding the block into the template page and not the global scrapbook (feels like I have more control and the client can't touch it).
Just another way of doing it, but Shoster's code sure is a lot less :)
$bt_main = BlockType::getByHandle('autonav'); $bt_main->controller->displayPages = 'top'; $bt_main->controller->orderBy = 'display_asc'; $bt_main->controller->displaySubPages = 'all'; $bt_main->controller->displaySubPageLevels = 'custom'; $bt_main->controller->displaySubPageLevelsNum = '2'; $bt_main->render('templates/header_menu_with_drop');
Just another way of doing it, but Shoster's code sure is a lot less :)
Hi Zoinks. In your original post where you say:
"The only way I could figure out how to add Auto Nav areas was to create page types with Editable Areas and then stick in an Auto Nav block and apply it to all Children of that page type."
Do you mean manualy apply it to the children of that page type one by one? Or is there a setting which allows the children pages to inherit the Auto-Nav of the specified block?
"The only way I could figure out how to add Auto Nav areas was to create page types with Editable Areas and then stick in an Auto Nav block and apply it to all Children of that page type."
Do you mean manualy apply it to the children of that page type one by one? Or is there a setting which allows the children pages to inherit the Auto-Nav of the specified block?
Oliver, I assume you discovered this but, Dashboard > Pages and Themes > Page Types > Defaults (of page type you want to edit) >
Add the Auto Nav, to the header,
Click on the Auto Nav
> Setup on Child Pages > Tick all Pages you would like the Block to appear on
Add the Auto Nav, to the header,
Click on the Auto Nav
> Setup on Child Pages > Tick all Pages you would like the Block to appear on
Hi Johndorsay,
How could I get this to hard-code just the items beneath a particular page?
$bt_main->controller->displayPages = 'top';
Pretty sure that's the line I need to change, but don't know what I should change it to.
How could I get this to hard-code just the items beneath a particular page?
$bt_main->controller->displayPages = 'top';
Pretty sure that's the line I need to change, but don't know what I should change it to.
You just need to add one parameter to the above code..
$bt_main->controller->displayPagesCID = '62'; // <-- Specify the CID of the page. ( Gets the first level of pages under that section )
thanks!
I have just a single conventional drop menu in the header region of my site, so the above code appears in my header.php theme template file. The nav menu is not editable when the page is in edit mode, and any changes to the block in the scrapbook are reflected site-wide.
-Steve