WebsiteBaker Support (2.8.x) > Templates, Menus & Design
show_menu2: valid XHTML and CSS selectable menus
Tim:
Hi Brofield,
I'm implementing another WB installation and using your wonderful code snippet :) This particular one has two menus - a top menu and a side menu. The top menu is all the root level pages. The side menu is related to that particular "area" of the page.
However I have one question - is there a way to make a menu such that if that page has children, its children are displayed, and if you go to one of those children, that menu changes to show that pages siblings?
In effect, that once you're in that "area" of the site, the menu will stay the same regardless of whether you're on the root page or one of the children.
The more that I think about it actually this is more of a php question...
Oh! Also. I found it useful to hack your code so that it would recognise [nbsp] as a spacer in the menu code. Saves having to use those annoying | vertical slashes to seperate menus. Just thought I'd share. ;)
Cheers,
Tim
brofield:
--- Quote from: Tim on August 30, 2006, 07:52:14 AM ---However I have one question - is there a way to make a menu such that if that page has children, its children are displayed, and if you go to one of those children, that menu changes to show that pages siblings?
--- End quote ---
You are always wanting to show the menu from the first level down, regardless of the currently selected menu. Therefore start is ROOT+1. Depth is to CURR+1.
show_menu2(0, SM2_ROOT+1, SM2_CURR+1);
See http://code.jellycan.com/sm2test/pages/enterprise.php "Children/Siblings"
--- Quote from: Tim on August 30, 2006, 07:52:14 AM ---Oh! Also. I found it useful to hack your code so that it would recognise [nbsp] as a spacer in the menu code. Saves having to use those annoying | vertical slashes to seperate menus. Just thought I'd share. ;)
--- End quote ---
Why? Just enter &nsbsp; directly into the format string. It isn't escaped by sm2.
e.g.
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, false, false, ' > <ol>', '</ol>');
B
Tim:
EDIT: I fixed it. I was still running an old version of show_menu2. (2.3.6) Cheers!
Hi Brofield,
Thanks for the reply. I must have missed that before! I do have one question though. When I implement this, it shows not only all the siblings of that page, but it shows all the pages at that level (ie pages that are children of a root page). Regardless of what page I'm on, I get a giant listing of all the pages which have a root page as a parent, even at pages which have no children.
This would be the equivalent, using your jellycan example, of always having a children/sibling menu which read "Jams, Cogs and Wheels, Large Objects, Small Objects, Procrastination, Drugs, Bold and Italics" regardless of what page you were on.
Yours however does the correct thing - when it's at a root page with no children, no menu comes up. However, I can't get mine to go away :(
Also, the
show_menu2(0, SM2_ROOT+1, SM2_CURR+1);
doesn't work for me unless I put a ' ', in there, e.g.
show_menu2(0, SM2_ROOT+1, SM2_CURR+1, ' ', [insert formatting stuff here]);
Without the spacer I just get the formatting stuff printed as text. What causes that?
Thanks for your patience.
Tim
learning:
I have been struggling with two issues for a few days now, and the worst part is, I am worried there are going to be a very simple solutions that I am missing. After much searching, and experimenting, I am finally posting... hopefully in the right area.
Issue 1
I had a menu structer that was working fine, however it would not function correctly in Fire Fox, so I converted to show_menu2. The menu itself, now displays and functions correctly... however one issue. The current menu css will not work. I have tried many different combinations and I just can not seem to get it to work. (again it was working fine with show_menu). I have included my css for my menu.. not sure if it will help or not.
Please not the 'current' css that I have quoted here is not all that I have tried, it is just the last one that I tried. I am sure this is something simple that I just can't figure out... sorry to be a bother. I can include the view source from my page if that helps too.
--- Code: ---#menu {
padding: 0;
margin: 0;
}
#menu a {
text-decoration: none;
display:block;
}
#menu ul {
padding: 0;
margin: 0;
list-style: none;
}
#menu li {
margin: 0;
padding: 0;
font-size: 11px;
font-family: Arial;
}
#menu ul li a {
margin-top: 8px;
padding: 0 28px;
height: 21px;
line-height: 21px;
font-weight: bold;
text-transform: uppercase;
border-top: 1px solid #AACCD5;
border-bottom: 1px solid #AACCD5;
background-image: url(li1a.gif);
background-position: 13px 5px;
background-repeat: no-repeat;
}
#menu ul li a.menu-current{
margin-top: 8px;
padding: 0 28px;
height: 21px;
line-height: 21px;
font-weight: bold;
text-transform: uppercase;
border-top: 1px solid #AACCD5;
border-bottom: 1px solid #AACCD5;
background-image: url(li1a-c1.gif);
background-position: 13px 5px;
background-repeat: no-repeat;
background-color: #FAF9D0;
}
#menu ul li ul li a {
margin-top: 0;
height:19px;
line-height: 19px;
font-weight:normal;
text-transform: capitalize;
background-image: url(li2.gif);
background-color: #DEECF0 ;
background-position: 13px 5px;
background-repeat: no-repeat;
border-top: 1px solid #EEF5F7;
border-bottom: 1px none #EEF5F7;
}
#menu ul li ul li a.menu-current{
margin-top: 0;
height: 19px;
line-height: 19px;
font-weight: normal;
text-transform: capitalize;
background-image: url(li2-c1.gif);
background-color: #FEF2B9;
background-position: 13px 5px;
background-repeat: no-repeat;
border-top: 1px solid #EEF5F7;
border-bottom: 1px none #EEF5F7;
}
--- End code ---
Issue 2.
I have a 'members' page... set to registered, and it wont show on the menu unless I am logged in. From my searching I can see that only 'private' pages should have this behaviour. Is there something I am doing wrong, or is it something to do with implementing show_menu2?
Sorry again to be a pain, I just thought it was time to post before I didn't have ANY hair left!!
Cheers
brofield:
Issue 1
If you are using the default format then the menu-current class is assigned to the <li> element, not the <a> element.
Issue 2
Surely this is what it should do? Pages only available to registered users will only appear in the menu if the registered user is logged in.
B
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version