How to make 2 autonav menus in one page
Permalink
Is it possible to have 2 separate autonav in one page? I have created 2 templates for my autonav, but then I tried to add them both, they interrupt with each other and I get a error message.
are you putting them both in the same area? Ive had two autonav's.. one at the top as standard and one in the sidebar. They seemed to work fine if I remember correctly. Tried emptying cache?
Hi,
It doesnt matter with area, if you put two autonav block in same area it should work and it does for me. Check your view.php and header.php and make sure that everything is correct.
Thanks
Vijay
It doesnt matter with area, if you put two autonav block in same area it should work and it does for me. Check your view.php and header.php and make sure that everything is correct.
Thanks
Vijay
What's the error message? I believe the only way two menus could conflict is if you have javascript code in the templates (and the js is conflicting).
Hi
Clear Cache didn't help.
I can't fine anything wrong with my view and header, but maybe there are.
I can easily have 2 auto-nav same time then i don't yous my templates, so the problem must be there.
Here is the templates codes:
The PHP is the same for both.
<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$aBlocks = $controller->generateNav();
global $c;
if ($c->isEditMode()) {
echo("
<div class=\"menu\" style=\"position:inherit!important;\">
<ul>");
}
else {
echo("
<div class=\"menu\">
<ul>");
}
$nh = Loader::helper('navigation');
foreach($aBlocks as $ni) {
$_c = $ni->getCollectionObject();
if (!$_c->getCollectionAttributeValue('exclude_nav')) {
$thisLevel = $ni->getLevel();
if ($thisLevel > $lastLevel) {
echo("<!--[if IE 7]><!--></a><!--<![endif]-->\n<!--[if lte IE 6]>
<table>
<tr>
<td><![endif]-->\n
<ul>\n");
} else if ($thisLevel < $lastLevel) {
for ($j = $thisLevel; $j < $lastLevel; $j++) {
echo("</a></li>
\n</ul>
\n<!--[if lte IE 6]></td>
</tr>
</table>
</a><![endif]--></li>
\n");
}
}
if ($thisLevel == $lastLevel && $i >0) {
echo "</a></li>
\n";
}
$pageLink = false;
if ($_c->getCollectionAttributeValue('replace_link_with_first_in_nav')) {
$subPage = $_c->getFirstChild();
if ($subPage instanceof Page) {
$pageLink = $nh->getLinkToCollection($subPage);
}
}
if (!$pageLink) {
$pageLink = $ni->getURL();
}
echo '
<li><a href="'.$pageLink.'">' . $ni->getName();
$lastLevel = $thisLevel;
$i++;
}
}
$thisLevel = 0;
for ($i = $thisLevel; $i <= $lastLevel; $i++) {
echo("</a></li>
</ul>
");
}
echo '</div>
';
?>
And the css nr 1
/*---------------------------------------Level 1--------------------------------------------------*/
.menu {width:800px; height:30px; position:relative; z-index:100;}
.menu li {float:left; width:151px; position:relative;}
/* style */
.menu a, .menu a:visited {display:block; font-size:12px; text-decoration:none; color:#fff; width:150px; height:30px; background:#09c; text-indent:10px; line-height:30px; font-weight:bold;}
/* style hover */
.menu a:hover {background:#0F0;}
/*----------------------------------------Level 2-------------------------------------------------*/
/* style */
.menu ul ul a, .menu ul ul a:visited {background:#d4d8bd; height:25px; line-height:25px;}
/* style hover */
.menu ul ul a:hover {background:#0F0;}
/* positon */
.menu ul ul {visibility:hidden; position:absolute; height:0; top:30px; left:0;}
/*------------------------------------------Level 3-----------------------------------------------*/
/* style */
.menu ul ul ul a, .menu ul ul ul a:visited {background:#e2dfa8;}
/* style hover */
.menu ul ul ul a:hover {background:#b2ab9b;}
/* position */
.menu ul ul ul {left:150px; top:0px;}
/*-----------------------------------------------------------------------------------------*/
.menu ul li:hover ul, .menu ul a:hover ul, .menu ul :hover ul :hover ul {visibility:visible; }
.menu ul :hover ul ul {visibility:hidden;}
/* remove all the bullets, borders and padding */
.menu ul {padding:0; margin:0; list-style-type:none;}
/* required for IE to work */
.menu table {position:absolute; top:0; left:0; border-collapse:collapse;;}
And the css nr 2.
/*---------------------------------------Level 1--------------------------------------------------*/
.menu {width:200px; position:relative; z-index:100;}
.menu li {float:left; width:151px; position:relative; margin-right:10px;}
/* style */
.menu a, .menu a:visited {display:block; font-size:12px; text-decoration:none; color:#fff; width:150px; height:30px; background:#09c; text-indent:10px; line-height:30px; font-weight:bold;}
/* style hover */
.menu a:hover {background:#F0F;}
/*----------------------------------------Level 2-------------------------------------------------*/
/* style */
.menu ul ul a, .menu ul ul a:visited {background:#d4d8bd; height:25px; line-height:25px;}
/* style hover */
.menu ul ul a:hover {background:#0F0;}
/* positon */
.menu ul ul {visibility:hidden; position:absolute; height:0; top:0px; left:150px;}
/*------------------------------------------Level 3-----------------------------------------------*/
/* style */
.menu ul ul ul a, .menu ul ul ul a:visited {background:#e2dfa8;}
/* style hover */
.menu ul ul ul a:hover {background:#b2ab9b;}
/* position */
.menu ul ul ul {left:150px; top:0px;}
/*-----------------------------------------------------------------------------------------*/
.menu ul li:hover ul, .menu ul a:hover ul, .menu ul :hover ul :hover ul {visibility:visible; }
.menu ul :hover ul ul {visibility:hidden;}
/* remove all the bullets, borders and padding */
.menu ul {padding:0; margin:0; list-style-type:none;}
/* required for IE to work */
.menu table {position:absolute; top:0; left:0; border-collapse:collapse;;}
Clear Cache didn't help.
I can't fine anything wrong with my view and header, but maybe there are.
I can easily have 2 auto-nav same time then i don't yous my templates, so the problem must be there.
Here is the templates codes:
The PHP is the same for both.
<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$aBlocks = $controller->generateNav();
global $c;
if ($c->isEditMode()) {
echo("
<div class=\"menu\" style=\"position:inherit!important;\">
<ul>");
}
else {
echo("
<div class=\"menu\">
<ul>");
}
$nh = Loader::helper('navigation');
foreach($aBlocks as $ni) {
$_c = $ni->getCollectionObject();
if (!$_c->getCollectionAttributeValue('exclude_nav')) {
$thisLevel = $ni->getLevel();
if ($thisLevel > $lastLevel) {
echo("<!--[if IE 7]><!--></a><!--<![endif]-->\n<!--[if lte IE 6]>
<table>
<tr>
<td><![endif]-->\n
<ul>\n");
} else if ($thisLevel < $lastLevel) {
for ($j = $thisLevel; $j < $lastLevel; $j++) {
echo("</a></li>
\n</ul>
\n<!--[if lte IE 6]></td>
</tr>
</table>
</a><![endif]--></li>
\n");
}
}
if ($thisLevel == $lastLevel && $i >0) {
echo "</a></li>
\n";
}
$pageLink = false;
if ($_c->getCollectionAttributeValue('replace_link_with_first_in_nav')) {
$subPage = $_c->getFirstChild();
if ($subPage instanceof Page) {
$pageLink = $nh->getLinkToCollection($subPage);
}
}
if (!$pageLink) {
$pageLink = $ni->getURL();
}
echo '
<li><a href="'.$pageLink.'">' . $ni->getName();
$lastLevel = $thisLevel;
$i++;
}
}
$thisLevel = 0;
for ($i = $thisLevel; $i <= $lastLevel; $i++) {
echo("</a></li>
</ul>
");
}
echo '</div>
';
?>
And the css nr 1
/*---------------------------------------Level 1--------------------------------------------------*/
.menu {width:800px; height:30px; position:relative; z-index:100;}
.menu li {float:left; width:151px; position:relative;}
/* style */
.menu a, .menu a:visited {display:block; font-size:12px; text-decoration:none; color:#fff; width:150px; height:30px; background:#09c; text-indent:10px; line-height:30px; font-weight:bold;}
/* style hover */
.menu a:hover {background:#0F0;}
/*----------------------------------------Level 2-------------------------------------------------*/
/* style */
.menu ul ul a, .menu ul ul a:visited {background:#d4d8bd; height:25px; line-height:25px;}
/* style hover */
.menu ul ul a:hover {background:#0F0;}
/* positon */
.menu ul ul {visibility:hidden; position:absolute; height:0; top:30px; left:0;}
/*------------------------------------------Level 3-----------------------------------------------*/
/* style */
.menu ul ul ul a, .menu ul ul ul a:visited {background:#e2dfa8;}
/* style hover */
.menu ul ul ul a:hover {background:#b2ab9b;}
/* position */
.menu ul ul ul {left:150px; top:0px;}
/*-----------------------------------------------------------------------------------------*/
.menu ul li:hover ul, .menu ul a:hover ul, .menu ul :hover ul :hover ul {visibility:visible; }
.menu ul :hover ul ul {visibility:hidden;}
/* remove all the bullets, borders and padding */
.menu ul {padding:0; margin:0; list-style-type:none;}
/* required for IE to work */
.menu table {position:absolute; top:0; left:0; border-collapse:collapse;;}
And the css nr 2.
/*---------------------------------------Level 1--------------------------------------------------*/
.menu {width:200px; position:relative; z-index:100;}
.menu li {float:left; width:151px; position:relative; margin-right:10px;}
/* style */
.menu a, .menu a:visited {display:block; font-size:12px; text-decoration:none; color:#fff; width:150px; height:30px; background:#09c; text-indent:10px; line-height:30px; font-weight:bold;}
/* style hover */
.menu a:hover {background:#F0F;}
/*----------------------------------------Level 2-------------------------------------------------*/
/* style */
.menu ul ul a, .menu ul ul a:visited {background:#d4d8bd; height:25px; line-height:25px;}
/* style hover */
.menu ul ul a:hover {background:#0F0;}
/* positon */
.menu ul ul {visibility:hidden; position:absolute; height:0; top:0px; left:150px;}
/*------------------------------------------Level 3-----------------------------------------------*/
/* style */
.menu ul ul ul a, .menu ul ul ul a:visited {background:#e2dfa8;}
/* style hover */
.menu ul ul ul a:hover {background:#b2ab9b;}
/* position */
.menu ul ul ul {left:150px; top:0px;}
/*-----------------------------------------------------------------------------------------*/
.menu ul li:hover ul, .menu ul a:hover ul, .menu ul :hover ul :hover ul {visibility:visible; }
.menu ul :hover ul ul {visibility:hidden;}
/* remove all the bullets, borders and padding */
.menu ul {padding:0; margin:0; list-style-type:none;}
/* required for IE to work */
.menu table {position:absolute; top:0; left:0; border-collapse:collapse;;}
Yes, after many hours I found a solution, I changes all the names with menu to menu-2 on one of the templates.