Page 1 of 1

Navigation Hierarchy Problems

Posted: Thu Mar 22, 2007 3:37 pm
by scottybowl
Hi,

I am currently building the following site: http://www.kdwebserver.co.uk/~coleago2/ ... ?page=home

It's just about finished but there is one problem which I can't make heads or tails of. Basically, under the navigation "Who we are > Coleago Consultants >" there are a list of consultants. When you click on one it takes you to their page. However, on the left side navigation it should show the third tier navigation (i.e the rest of the consultants). Instead, it is showing the Training menu.

At the top of the left navigation I have outputed the variable $h_parent which shows which navigation item is the parent of the current page to help demonstrate what is happening. The parent for the consulting pages should be 2.4 but instead it is outputting "4" (perhaps it is outputting that the parent is the 4 part of the 2.4?)

I have detailed the code used for the relevant sections of the navigation:

In the page template

Code: Select all

{hierarchy}
Parent: {$h_parent}
{cms_module module='menumanager' start_element=$h_parent template='ColeagoSide'}
In the menu template

Code: Select all

{assign var="startshowing" value="0"}
{if $count > 0}

<ul class="menu_horiz">
{php}
$firstRun = "yes";
{/php}
{foreach from=$nodelist item=node}
{php}
if($firstRun == "yes") {
$firstRun = "no";
{/php}
<p><img src="uploads/images/titles/{$node->menutext}.gif" border="0" alt="{$node->menutext}" /></p>
{php}
} else {
{/php}
<li><a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a></li>
{php}
}
{/php}
{/foreach}
</ul>
{/if}
Any help on this matter would be greatly appreciated!

Thanks  :)

Scott

Re: Navigation Hierarchy Problems

Posted: Thu Mar 22, 2007 3:49 pm
by heatherfeuer
When you are in the admin --> pages area, what is the hierarchy of consultant pages?

For instance, when you click on the top "who we are" menu, what is the actual page number for that?  Is it like this:
2 - Who We Are
2.1 - Consultants - Subheading
2.1.1 - Consultant One
2.1.2 - Consultant Two
...ad nauseum

If you have the hierarchy like that, then you shouldn't be seeing the vertical menu switching to training.  But it looks to me like you don't have the pages set up that way.  Make sure that each consultant's page is a child of the "Consultants" subheading.

Re: Navigation Hierarchy Problems

Posted: Thu Mar 22, 2007 3:52 pm
by scottybowl
here is a snippet of the current hierarchy:

2 Who we are
2.1 -  Overview
2.2 -  Clients
2.3 -  Expertise and Example Projects
2.4 -  Coleago Consultants
2.4.1 -  -  Stefan Zehle
2.4.2 -  -  Sumiati Djoko
2.4.3 -  -  Steve Hobbs

and so on... it is set up correctly, which is why I'm stumped!

Re: Navigation Hierarchy Problems

Posted: Thu Mar 22, 2007 6:35 pm
by heatherfeuer
Huh.  You are using the exact same template for all the pages?  Or is there a different template for different areas?

Looking at the numbering and the fact that on the consultant pages the sidebar content switches to the Parent 4, it's almost as if from 2.4 to 2.4.1 the 2. part is getting dropped, so the menu is starting a new display starting at 4.x.  All I can think is that in your code for the sidebar menu, page numbers that are 2.x.x are not being parsed correctly by the script.

Are the consultant pages the only ones that are X.x.x hierarchy?

Re: Navigation Hierarchy Problems

Posted: Mon Mar 26, 2007 11:10 am
by scottybowl
different template for different pages, but the navigation template is identical for all the pages

the consultant pages are the only ones with the x.x.x hierarchy, any help would be appreciated

Re: Navigation Hierarchy Problems

Posted: Mon Mar 26, 2007 1:29 pm
by heatherfeuer
Well, I'm stumped at the moment.  I guess my brain isn't sufficiently awake!  ;D  Hopefully someone else can help you.  I'm sorry!

Re: Navigation Hierarchy Problems

Posted: Mon Mar 26, 2007 3:14 pm
by scottybowl
ok, ive figured out how to fix it....

the problem was in the user defined tag outlined in the help files. The code wasnt outputting the full value of the menus hierarchy

for eg, it would out the parent digit of 3.2.1 (in this case 2) instead of 3.2. The code I wrote in the user defined tag is below, it could probably be done in fewer lines but I've had enough of it now and don't particularly care!

Code: Select all

global $gCms;
$pos = $gCms->variables['position'];
$base = explode('.', $pos);
$totalDepth = count($base);

$parentDepth = $totalDepth -1;

$count = 1;


// loop through all the base values (the base values hold the single
// digit value of the menu heirarchy)
foreach($base as $parentLevel) {
    if($count <= $parentDepth) {
        // trim all the excessive 0's
        $parentLevel = ltrim($parentLevel, "0" );

        if($parentDepth == $count) { // recreate the hierarchy number eg 3.1.1
            $theParent .= $parentLevel;
        } else {
            $theParent .= $parentLevel . ".";
        }
    }
  $count++;
}


$smarty->assign('h_toplevel', $base[0] * 1);
$smarty->assign('h_parent',   $theParent);
$smarty->assign('h_this',     $base[count($base)-1] * 1);


Re: Navigation Hierarchy Problems

Posted: Tue Mar 27, 2007 10:17 am
by scottybowl
Have changed the code slightly because there was a bug or two, also added a new variable "$thisLevel" which will output the value of the current pages page hierarchy (different way of outputting as the original seemed to be buggy)

Code: Select all

global $gCms;
$pos = $gCms->variables['position'];
$base = explode('.', $pos);
$totalDepth = count($base);
$parentDepth = $totalDepth;
$count = 0;

foreach($base as $parentLevel) {
    $parentLevel = ltrim($parentLevel, "0" );
    if($count <= $parentDepth) {
        $thisLevel .= $parentLevel . ".";
    }
   if($count < $parentDepth) {    
        $theParent .= $parentLevel . ".";
    }
  $count++;
}

$smarty->assign('h_toplevel', $base[0] * 1);
$smarty->assign('h_parent', rtrim($theParent, "." ));
$smarty->assign('h_this',  rtrim($thisLevel, "." ));


Re: Navigation Hierarchy Problems

Posted: Thu Oct 25, 2007 11:46 am
by stopsatgreen
I just wanted to say thank you for this! I had the original hierarchy code which wasn't giving me the right results, and I thought I was going crazy! This new code gives me the result I expected; thank you!!!

Re: Navigation Hierarchy Problems

Posted: Thu Oct 25, 2007 12:38 pm
by stopsatgreen
May have spoken too soon; this script returns $h_parent and $h_this as having the same value. That can't be right...