WebsiteBaker Community Forum (upd)

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: mdemaree99 on June 22, 2012, 09:28:28 PM

Title: showmenu
Post by: mdemaree99 on June 22, 2012, 09:28:28 PM
Before I start some testing this weekend..
as anybody had any luck with multiple color background on menu buttons?
I am looking to add a class of group1, group2, group3 that would each have their own background color.
Here is what I was thinking:
Yes.. I know code looks a little funny..  My template is a little odd and I have 2 menus on the page..
Top Menu lists Public and Members.
Main page  shows menu of all pages under Public section, hence the Root+1.

<?php show_menu2(
0,
 
SM2_ROOT+1,
 
SM2_ALL,
 
SM2_ALL|SM2_CURRTREE,
 
'<li]"><a href="[url]" class="[class] navlev[level] group.$menucount">[menu_title]</a>',
"</li>",
'<ul class="ullev[level]">',
"</ul>",
true,
'<ul id="header_menu" class="menu"><li class="home"></li>'
);

'[if([leve]==1){$menucount=menucount+1 }]'

 
?>
Title: Re: showmenu
Post by: marmot on June 23, 2012, 06:45:21 PM
Hi,

do I get you right, you need a different class for each menu button? Hmm, I guess it could look a bit funny to have each button in different design...
Maybe [page_id] can help you:.... '<li]"><a href="[url]" class="[class] navlev[level] group[page_id]">[menu_title]</a>',....


regards
Title: Re: showmenu
Post by: mdemaree99 on June 25, 2012, 04:29:36 PM
Looking to make it as fluid as possible and not hard code page_id's
Easier to code CSS for 8 classes  so if user adds or deletes a page they wouldn't have to change template file.

Was hoping I could replate [level] with another variable that changes for each menu top level item vs sub-menu's

Here is menu I am trying to mimic.
http://www.jld.net/

Title: Re: showmenu
Post by: marmot on June 25, 2012, 09:30:40 PM
Hi,

Quote from: mdemaree99 on June 25, 2012, 04:29:36 PM
Was hoping I could replate [level] with another variable that changes for each menu top level item vs sub-menu's
ok, I've got two approaches for you:

1) Use the include.php appended instead of the original one of SM2. Using SM2 Parameter SM2_NUMCLASS will give each item a class like "menu-0_2", where 0 is the level of the menu and 2 is the number of the item (starting at 0).
In .css file you can define .menu a.menu-0_2 {
background-color: #0F0;
}
for example. But be sure to add the definition at the end of the file so previous definitions will be overwritten.

2) If you have jquery on your page and don't want to touch the original SM2 code, you can put this script in the head section of your template (of course after jquery is loaded): <script>
$(document).ready(function () {
$('.menu-0').each(function(index){
$(this).addClass('menuColor'+index);
});
});
</script>
, where 0 in menu-0 is the level of the menu.
Then you can define styles in your css selecting like this:.menu a.menuColor1 {
color: #00F;
}
, where 1 of menuColor1 is the number of the menuitem, starting with 0.

Both suggestions are tested so be sure - they work  :-D

regards

Edit: Typos
Title: Re: showmenu
Post by: DarkViper on June 25, 2012, 10:36:22 PM
The problem from mdemaree99 is a very good example to show how WB from revision 1689 (currently in SVN) will handle this:

<?php

'<li]"><a href="[url]" class="[class] navlev[level]" style="background-image:url([menu_icon_0]);">[menu_title]</a>',



In Backend -> Page-Settings you can(but not must) now assign different images to 'MenuIcon0' of each page.
(this functionality is given also with 'menu_icon_1' and 'page_icon')

that's all..
Title: Re: showmenu
Post by: mdemaree99 on June 26, 2012, 05:51:47 AM
Quote from: marmot on June 25, 2012, 09:30:40 PM
2) If you have jquery on your page and don't want to touch the original SM2 code, you can put this script in the head section of your template (of course after jquery is loaded): <script>
$(document).ready(function () {
$('.menu-0').each(function(index){
$(this).addClass('menuColor'+index);
});
});
</script>
, where 0 in menu-0 is the level of the menu.
Then you can define styles in your css selecting like this:.menu a.menuColor1 {
color: #00F;
}
, where 1 of menuColor1 is the number of the menuitem, starting with 0.


Seems like I have several jquery files loading so I like option 2, but a little confused on what is the variable I would use for the class. I have tried menucolor[index] and a few other options, but not quite sure the code.

<?php show_menu2(0, SM2_ROOT+1, SM2_ALL, SM2_ALL|SM2_CURRTREE, '<li><a href="[url]" class="
menuColor[index]">[menu_title]</a>', "</li>", '<ul class="ullev[level]">', "</ul>", true, '<ul id="header_menu" class="menu"><li class="home"></li>');
?>
Title: Re: showmenu
Post by: marmot on June 26, 2012, 08:07:32 PM
Hi,

Quote from: mdemaree99 on June 26, 2012, 05:51:47 AM
Seems like I have several jquery files loading so I like option 2, but a little confused on what is the variable I would use for the class. I have tried menucolor[index] and a few other options, but not quite sure the code.
to use this you just have to use the SM2 Paramenter SM2_NUMCLASS. The javascript will add the unique class to the link. Just define the style how you like it. Thats all! You don't have to care for classes.

regards