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

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
hannson

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

Post 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?
Last edited by hannson on Wed Aug 22, 2007 2:30 pm, edited 1 time in total.
KO
Power Poster
Power Poster
Posts: 562
Joined: Mon Nov 06, 2006 7:55 pm

Re: Menu Template, display parent in the subnavigation.

Post by KO »

What is the reason of having empty in?
hannson

Re: Menu Template, display parent in the subnavigation.

Post 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
cyberman

Re: Menu Template, display parent in the subnavigation.

Post 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  ::) ...
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Menu Template, display parent in the subnavigation.

Post 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...
hannson

Re: Menu Template, display parent in the subnavigation.

Post 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.
Last edited by hannson on Wed Aug 22, 2007 2:31 pm, edited 1 time in total.
hannson

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

Post 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)
cyberman

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

Post by cyberman »

Sorry. Cant see a difference to suggested (and shown) solution ::) ...
KO
Power Poster
Power Poster
Posts: 562
Joined: Mon Nov 06, 2006 7:55 pm

Re: Menu Template, display parent in the subnavigation.

Post 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
hannson

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

Post 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).
Last edited by hannson on Thu Aug 23, 2007 11:38 am, edited 1 time in total.
cyberman

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

Post 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
hannson

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

Post by hannson »

Never mind, I hacked it together and it works as planned now :)

thanks for your help!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
cyberman

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

Post by cyberman »

calguy1000 wrote: I can paste the UDT if you like.
Would be nice ...
Locked

Return to “Layout and Design (CSS & HTML)”