Page 1 of 1

changing colors for odd and even navigation elements

Posted: Mon Sep 03, 2007 12:52 pm
by barry cooper
Hi again,

I am trying to use smarty cycle:

{section name=name loop=$menu}
{$menu[name]}
{/section}

to change the alternate the background color in a vertical nav bar. All achieve something like http://tatteredfly.com/

I am using the following CSS:

div#menu_vert {
  margin:0;
  padding:0;
  color:#333399;
}

div#menu_vert li {
  list-style:none;
  margin-bottom:2px;
  padding:4px 4px 4px 10px;
}

div#menu_vert li.odd {
  background:#33CC99;
}

div#menu_vert li.even {
  background:#009933;
}

I am using the following tag to insert the nav bar info:

{menu template='simple_navigation.tpl' collapse='1'}

My question is what do I have to do to the smarty cycle code to make this work?  I am not sure which bits of the code to alter.

Many Thanks

Barry Cooper

Re: changing colors for odd and even navigation elements

Posted: Mon Sep 03, 2007 1:35 pm
by KO
You might want to check that menu template simple_navigation.tpl and look for code

Code: Select all

{else}
<li><a href="{$node->url}"
change it

Code: Select all

{else}
<li class="{cycle values="even,odd"}"><a href="{$node->url}"
Maybe that is the place you are looking for...

Br, K

Re: changing colors for odd and even navigation elements

Posted: Mon Sep 03, 2007 1:56 pm
by barry cooper
Is there a way of modifying the menu manager code and saving under  the same name.

Thanks

Baz C

Re: changing colors for odd and even navigation elements

Posted: Mon Sep 03, 2007 1:59 pm
by RonnyK
Barry,

I don't think that that works, as you are now working with the .tpl version. That one is the file-version. When you press the import-button on that menu, you can import it to the DB and give it a name. I think it is good to give it another name as well, as you'll know it's changed from the standard. After giving it a name, you have to change the calling in the template, changing to the new name, AND WITHOUT .tpl, as it is a DB-template.

Ronny

Re: changing colors for odd and even navigation elements (SOLVED)

Posted: Mon Sep 03, 2007 2:13 pm
by barry cooper
This is the best Forum ever.

MANY MANY THANKS!!!

Regards

Barry Cooper

Re: changing colors for odd and even navigation elements

Posted: Mon Sep 03, 2007 2:56 pm
by calguy1000
Please refrain from dual posting.