custom auto-nav
Permalink
Hi again,
I'm trying to adapt my wordpress theme to C5, but i have problems with auto-nav customization.
I'd like to have an autonav block with separators between items of my menu, like this
Item 1
Item 2
______
Item 3
Item 4
Item 5 etc...
So what i did in default.php was:
Then i have put autonav blok in each area.
The problem is: how can i select wich item i want in each area ?
Or perhaps there's a way to customize autonav template to do that ?
Any idea ?
Thanks !
I'm trying to adapt my wordpress theme to C5, but i have problems with auto-nav customization.
I'd like to have an autonav block with separators between items of my menu, like this
Item 1
Item 2
______
Item 3
Item 4
Item 5 etc...
So what i did in default.php was:
<?php $a = new Area('Menu1'); $a->display($c); ?> <div class="blackline"> </div> <?php $a = new Area('Menu2'); $a->display($c); ?>
Then i have put autonav blok in each area.
The problem is: how can i select wich item i want in each area ?
Or perhaps there's a way to customize autonav template to do that ?
Any idea ?
Thanks !
... i've found the solution playing with autonav templates and getCollectionAttributeValue (adding checkboxes to template pages)...
I have a question along the lines of this topic.. I'm wanting to change the color scheme of the Auto-Nav template and can't seem to find anything relating to color or formatting of any kind.. Where would I find this?
use custom templates to make the presentation layer of any block look however you want it to..
you can set the custom template on any existing block when you click it.. just look for it in the same menu you hit edit for a block on.
you can set the custom template on any existing block when you click it.. just look for it in the same menu you hit edit for a block on.
I understand how to set the template.. I'm wanting to *change* the template coding to change the colors of the template, and in the main template .php file I can't find anything stating what color it's set as, so I'm figuring that it's a seperate .css file, but I can't find anything relating to auto-nav templates...
When you make your own template for the autonav, give the UL a unique class or id. Once you apply the template, the nav will have those attributes, which you can target with your site's custom CSS code. Just add whatever rules you need to your existing CSS code to make the template whatever color you want.
I'd like to be able to find the last object in the generated nav in the file header_menu.php. The reason is I'd like the last item in the menu to be treated differently.
I'm not a saavy PHP developer, I just know enough to get in trouble.
Does someone have a solution, or does the API offer a simple way to find it in the foreach statement?
Thanks.
I'm not a saavy PHP developer, I just know enough to get in trouble.
Does someone have a solution, or does the API offer a simple way to find it in the foreach statement?
Thanks.
create a new template for the auto-nav by copying/renaming view.php to ../auto-nav/templates.
first we have to count how much elements are in the current view, so add
to line 4 and 5;
to add the class name 'last' to the last element, we need a mod at line 38:
we only have to increase our token at line 52, between the last two closing brackets
regards
first we have to count how much elements are in the current view, so add
$aBlCnt = count($aBlocks); $tkn = 0;
to line 4 and 5;
to add the class name 'last' to the last element, we need a mod at line 38:
if ($tkn == $aBlCnt-1) $isLastClass = 'last'; else $isLastClass = ''; echo '<li class="'.$navSelected.' '.$isFirstClass.' '.$isLastClass.'">';
we only have to increase our token at line 52, between the last two closing brackets
$tkn++;
regards
Perfect! It was count() that I was looking for.
Thank you for taking the time to answer!
Thank you for taking the time to answer!
Hmmm.... I did this and it simply removed my last link in my menu. Did I do something wrong?
And then this was my CSS which I applied to the "last" class of the LI:
#navigation ul li.last a { text-decoration: none; color: #213647; }
It just removed my last button on the menu completely.
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $aBlocks = $controller->generateNav(); $c = Page::getCurrentPage(); $aBlCnt = count($aBlocks); $tkn = 0; echo("<ul class=\"nav\">"); $nh = Loader::helper('navigation'); //this will create an array of parent cIDs $inspectC=$c; $selectedPathCIDs=array( $inspectC->getCollectionID() ); $parentCIDnotZero=true; while($parentCIDnotZero){ $cParentID=$inspectC->cParentID; if(!intval($cParentID)){
Viewing 15 lines of 68 lines. View entire code block.
And then this was my CSS which I applied to the "last" class of the LI:
#navigation ul li.last a { text-decoration: none; color: #213647; }
It just removed my last button on the menu completely.
Thought I would post for reference and people who come across this via search.
The above solution doesn't quite work.
$count = count($aBlocks);
Counts all pages, including those that are excluded from the navigation. So if you have 4 pages and 3 excluded pages the count will be 7. This means the last page will not be detected correctly and the class won't be applied as desired.
To get around this you need to subtract the exlcuded pages from your count as follows:
The above solution doesn't quite work.
$count = count($aBlocks);
Counts all pages, including those that are excluded from the navigation. So if you have 4 pages and 3 excluded pages the count will be 7. This means the last page will not be detected correctly and the class won't be applied as desired.
To get around this you need to subtract the exlcuded pages from your count as follows:
foreach($aBlocks as $ni) { $_c = $ni->getCollectionObject(); if ($_c->getCollectionAttributeValue('exclude_nav')) { $count--; } }
Neither of the solutions work as expected since as OllieRattue explained: there may be hidden elements in navigation.
However, decreasing array size (count) for hidden navigation elements may not work well if your hidden elements are located at the end of the sitemap...
So you can use pseudo css element property as:
However, decreasing array size (count) for hidden navigation elements may not work well if your hidden elements are located at the end of the sitemap...
So you can use pseudo css element property as:
#navigation ul li:last-child { border-right: none; }