Page 1 of 2

Menu Template, display parent in the subnavigation. [not solved]

Posted: Wed Aug 22, 2007 12:19 am
by hannson
ok, Hi all!

I've been using CMSMS for a while now and I'm redesigning my site. It's all working fine btw and I want to begin to thank the CMSMS developers.

So my issue is maybe that I've been staring at the code for so long, I don't know what it is but here's what I want to achieve:

My menu template is a 2 level navigation, that is childs are displayed when I hover the parent etc. and it's working very well.

Code: Select all

<div id="navigation"> 
 {if $count > 0}
  <ul>
   {foreach from=$nodelist item=node}
    {if $node->depth > $node->prevdepth}
     {repeat string="<ul>" times=$node->depth-$node->prevdepth}
    {elseif $node->depth < $node->prevdepth}
     {repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
   </li>
{elseif $node->index > 0}</li>
{/if}
{if $node->current == true or $node->parent == true}
<li class="active">
<a href="{$node->url}" 
{if $node->target ne ""} 
target="{$node->target}"{/if}>{$node->menutext}</a>{if $node->depth == 1}{if !$node->haschildren}
<ul></ul>
{/if}{/if}
{else}
<li><a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a>{if $node->depth == 1}{if !$node->haschildren}
<ul></ul>
{/if}{/if}
{if{/if}
{/foreach}

{repeat string="</li></ul>" times=$node->depth-2}</li>
</ul>
{/if}
</div>
The {if !$node-haschildren} clause is for CSS purposes (I need a inside every root )


So what this code would output is:

Code: Select all

<div id="navigation"> 
<ul>
<li class="active"><a href="http://rafsol.is/index.php/heim" >Heim</a><ul></ul>

</li>
<li><a href="http://rafsol.is/index.php/um_okkur">Um okkur</a><ul>
<li><a href="http://rafsol.is/index.php/um_okkur/sagan">Sagan</a></li>
<li><a href="http://rafsol.is/index.php/um_okkur/opnunartimar">Opnunartímar</a></li>
<li><a href="http://rafsol.is/index.php/um_okkur/hafdu_samband">Hafðu Samband</a>
</li></ul>
</li>
<li><a href="http://rafsol.is/index.php/vorulisti">Vörulisti</a><ul>
<li><a href="http://rafsol.is/index.php/vorulisti/dyrasimakerfi">Dyrasímar - kerfi</a></li>
<li><a href="http://rafsol.is/index.php/vorulisti/hotelvorur">Hótel- & heimilisvörur</a></li>

<li><a href="http://rafsol.is/index.php/vorulisti/raflagnaefni">Raflagnaefni</a></li>
<li><a href="http://rafsol.is/index.php/vorulisti/lampar_og_ljosaskilti">Lampar og ljósaskilti</a></li>
<li><a href="http://rafsol.is/index.php/vorulisti/ljosaperur">Ljósaperur</a></li>
<li><a href="http://rafsol.is/index.php/vorulisti/tofluefni">Töfluefni</a>
</li></ul>
</li>
<li><a href="http://rafsol.is/index.php/thjonusta">Þjónusta</a><ul>
<li><a href="http://rafsol.is/index.php/thjonusta/fasdfa">Rafverktakar</a>
</li></ul>
</li>
<li><a href="http://rafsol.is/index.php/frodleikur">Greinar</a><ul>

<li><a href="http://rafsol.is/index.php/frodleikur/tilvarnarthjofum">Til varnar þjófum</a>
</li></ul>
</li>
<li><a href="http://www.rafsol.is/index.php/um_okkur/hafdu_samband">Hafðu samband</a><ul></ul>

</li>
</ul>
</div>
So basically what I have is a pretty basic CSS hover menu. What I'm trying to do is getting the parent link on top in the subnavigation; if the parent has a child;
like so:




Heim


Um okkur
Um okkur
Sagan
Opnunartímar
Hafðu Samband


Vörulisti
Vörulisti
Dyrasímar - kerfi
Hótel- & heimilisvörur

Raflagnaefni
Lampar og ljósaskilti
Ljósaperur
Töfluefni


Þjónusta
Þjónusta
Rafverktakar


Greinar
Greinar

Til varnar þjófum


Hafðu samband






Do you get the idea? I need a template that lets every parent have a inside (even if it's empty), and puts the parent item also in the subnavigation at top.

Can anyone here help me solve the problem?

Re: Menu Template, display parent in the subnavigation.

Posted: Wed Aug 22, 2007 6:42 am
by KO
What is the reason of having empty in?

Re: Menu Template, display parent in the subnavigation.

Posted: Wed Aug 22, 2007 7:31 am
by cyberman

Re: Menu Template, display parent in the subnavigation.

Posted: Wed Aug 22, 2007 11:04 am
by hannson
KO wrote: What is the reason of having empty in?
That's besides the point, but it´s for consistency in they layout. If you'd look at the site you'd see a black navigation to the left and a gray one to the right of it. The gray navigation is the and it needs to be displayed for each parent. CSS takes care of the rest. I hope that answers your question.

I'll be checking out
http://wiki.cmsmadesimple.org/index.php ... c_sub-menu and will be back if I can't figure it out.

Thanks for your input

Re: Menu Template, display parent in the subnavigation.

Posted: Wed Aug 22, 2007 11:22 am
by cyberman
hannson wrote: I'll be checking out
http://wiki.cmsmadesimple.org/index.php ... c_sub-menu and will be back if I can't figure it out.
Not sure if it does what you mean but I've created an example here

http://test.cmsmadesimple.de/index.php?page=archiv

Maybe I've missunderstood your request  ::) ...

Re: Menu Template, display parent in the subnavigation.

Posted: Wed Aug 22, 2007 1:05 pm
by Dr.CSS
What he has going so far looks cool, but I think what they are going for is to have the submenu on the right to have the active parent page show on left whether it has children or not...

Personally I think it's great the way it is...

Re: Menu Template, display parent in the subnavigation.

Posted: Wed Aug 22, 2007 1:52 pm
by hannson
mark wrote: What he has going so far looks cool, but I think what they are going for is to have the submenu on the right to have the active parent page show on left whether it has children or not...

Personally I think it's great the way it is...
I just figured one thing out; I can just place a link in the sub-menu manually and not put it in the template. I think that's the way to go, but thanks everybody for your help and comments!

@cyberman

I'm not sure what I'm looking at but I think it's not what i'm looking for, but thanks anyway!

Problem solved!


Edit: Problem is NOT solved.

If I add the link manually via the page editor it does not appear active. Back to square one.

Re: Menu Template, display parent in the subnavigation. [not solved]

Posted: Wed Aug 22, 2007 5:44 pm
by hannson
So to clear things up: I can't use a "content type: link" in  CMSMS content->pages because the link doesn't show as class="active" at the same time as the parent.

So the hierarchical of the menu (or what I want) looks like this


--------------------------------------------------------------

# Heim (no children so "Heim" won't show in the submenu)

# Um okkur (active)

    * Um okkur (active, same url as parent)
    * Sagan
    * Opnunartímar
    * Hafðu Samband

# Vörulisti
   
    * Vöruslisti (same url as parent)
    * Dyrasímar - kerfi
    * Hótel- & heimilisvörur
    * Raflagnaefni
    * Lampar og ljósaskilti
    * Ljósaperur
    * Töfluefni

# Þjónusta

    * Þjónusta (same url as parent)
    * Rafverktakar

# Greinar

    * Greinar (same url as parent)
    * Til varnar þjófum

# Hafðu samband (no children so "Hafðu samband" won't show on the submenu either)

--------------------------------------------------

I need a menu template that does that. The maximum depth of the menu is root and submenu (2 levels)

Re: Menu Template, display parent in the subnavigation. [not solved]

Posted: Wed Aug 22, 2007 6:30 pm
by cyberman
Sorry. Cant see a difference to suggested (and shown) solution ::) ...

Re: Menu Template, display parent in the subnavigation.

Posted: Thu Aug 23, 2007 7:31 am
by KO
hannson wrote:
KO wrote: What is the reason of having empty in?
That's besides the point, but it´s for consistency in they layout. If you'd look at the site you'd see a black navigation to the left and a gray one to the right of it. The gray navigation is the and it needs to be displayed for each parent. CSS takes care of the rest. I hope that answers your question.
Ok. I was just curious as it makes your pages not to validate but I'm sure you are aware of that.

One thing I noticed when looking your pages with wide screen is that the main text area jumps in Firefox 2 to the right if open up screen all the way.

Br, K

Re: Menu Template, display parent in the subnavigation. [not solved]

Posted: Thu Aug 23, 2007 11:10 am
by hannson
@KO
I'm aware it doesn't validate but it's the only way to show a blank submenu when hovered. I'm also aware of the text area (I've got a 22" widescreen at home), but that's a issue I haven't yet worked on.

@Cyberman

I'm not sure I see your solution in http://test.cmsmadesimple.de/index.php?page=archiv

EDIT:

If the whole template is your suggestion you've got me wrong; I'm using a single menu template while it appears that you're using two (one for root elements and a second for the submenu).

Re: Menu Template, display parent in the subnavigation. [not solved]

Posted: Thu Aug 23, 2007 12:39 pm
by cyberman
Maybe I've missunderstood, maybe you've changed your first posting too late :).

What do you want that default CSSMenu MenuManager template not does?

(default template has a if there are children)

Please look at this example

http://test.cmsmadesimple.de/index.php?page=climberusa

You will found this in source
9: climberusa

9.1: climberusa 1

9.2: climberusa 2

Re: Menu Template, display parent in the subnavigation. [not solved]

Posted: Thu Aug 23, 2007 4:29 pm
by hannson
Never mind, I hacked it together and it works as planned now :)

thanks for your help!

Re: Menu Template, display parent in the subnavigation. [not solved]

Posted: Thu Aug 23, 2007 6:16 pm
by calguy1000
To do this, I wrote a UDT that would get the top level page alias from any child.  I then used the results of that in a menu call.

i.e:

Code: Select all

{get_top_parent from=$page_alias assign='parent_item'}
{menu start_page=$parent_item}
no menumanager template changes needed for this.

I can paste the UDT if you like.

Re: Menu Template, display parent in the subnavigation. [not solved]

Posted: Thu Aug 23, 2007 7:22 pm
by cyberman
calguy1000 wrote: I can paste the UDT if you like.
Would be nice ...