Updated to version 1.4. Details in the main post. Updated zip file in the main post. test site available once again. I'm spent.
Valid XHTML
The existing menu function generates HTML that doesn't validate. Minor concern really, but many people like to have valid HTML.
<ul>
<li>item</li>
<li>item
<li>
<ul>
<li current>item<li></li></li>
<li>item</li>
</ul>
</li>
</li>
<li>item</li>
</ul>
Warning: array_keys(): The first argument should be an array in .....\modules\show_menu2\include.php on line 247
Had a main Page wich has visibility public and two subpages under this with visibility hidden. If i click on the public page link got the following error:Code: [Select]Warning: array_keys(): The first argument should be an array in .....\modules\show_menu2\include.php on line 247
I Have two menus. One horizontal wich only plays the root level and a vertical submenu wich only should display the subnavigation.
<snip>
when you on Main Page it shows in the submenu Subpage1 what is ok
when you on Subpage1 it shows in the submenu Subpage1, Subpage 1.1 and Subpage 1.2 what i dont like.
I'm looking for the parameter wich shows me on the Subpage1 in the submenu only the Subpage 1.1 and Subpage 1.2.
Could you pleas give me a hint how to get this?
Hello,Thanks, Matthias... the thing is that this is hard-coded, and I want *only* those particular links you see there, not every page that gets created at the root level. Make sense? Will this still work somehow?
this snippet seems what you need. Looked at the link you posted above. You have a horizontal menu wich should only show the root level. This you got in your template with <?php show_menu2(1, SM2_ROOT, SM2_START); ?>. And the menu on your right side wich shows all pages you got with <?php show_menu2(); ?>.
The Layout you define in the screen.css. Your existing one should work without changes. (not shure, done only a short look on it)
Matthias
Is there a way I can work with this code snippet to provide an "on state" for links I'm "hard-coding" into the template?
Warning: array_keys() [function.array-keys]: The first argument should be an array in C:\Intranet\Apache2\htdocs\modules\show_menu2\include.php on line 123
Warning: Invalid argument supplied for foreach() in C:\Intranet\Apache2\htdocs\modules\show_menu2\include.php on line 123
I don't see how this is different from http://riseup.co.nz/pages/flidget.php
It has no subpages, yet there is no error from it.
@brofield
Can you modify the wrapper functions page_menu() and
show_menu() to utilize your script but keep the current order
of parameters (for backwards compatibility) ?
font-weight is inherited by the child menus. Try
.menu-expand > a { font-weight: bold; }
This will only modify the <a> links directly underneath a .menu-expand classed tag and no children.
.menu-child{
background-color: #F3F3F3;
border : 1px solid #EEEEEE;
font-weight: normal;
}
.menu-current{
background-color: #DDDDDD;
border : 1px solid #16B144;
}
.menu-expand {
font-weight: bold;
}
<?php show_menu2(0, SM2_ROOT+1, SM2_START) ?>
your menu function looks quite impressive: I'm trying to have a menu like this, where all the
home | study | about
is there a way to get this?
I only get it to look like home | study | about |
obviously, the red vertical bar at the end is ugly. Does anybody have a solution for this?
Thanks a lot
Thanks. Looks like I was looking at an older doc. I did change it to [page] but it still shows the menu title. :?
I did have a suggestion for the future as well. Maybe you can add a feature to optional show the meta description/keywords as well. This can be useful in the sitemap for example where I can show the title and short description of each page. For example
Sitemap
Graphics
- Photoshop
- Plugins - Add features to your program with these free plugins. [keywords: art, design]
@brofield
I spotted this error in my scripts.log file. Not sure if it is important.
PHP Warning: array_keys(): The first argument should be an array in /modules/show_menu2/include.php on line 124
your menu function looks quite impressive: I'm trying to have a menu like this, where all the
home | study | about
is there a way to get this?
I only get it to look like home | study | about |
obviously, the red vertical bar at the end is ugly. Does anybody have a solution for this?
<div class="menu">
<ul class='menu-top'>
<li class='menu-sibling'><a href='http://code.jellycan.com' target='_top'>Home</a></li>
<li class='menu-sibling'><a href='http://code.jellycan.com/simpleopt/' target='_top'>SimpleOpt</a></li>
<li class='menu-sibling'><a href='http://code.jellycan.com/simpleini/' target='_top'>SimpleIni</a></li>
<li class='menu-sibling'><a href='http://code.jellycan.com/moji/' target='_top'>Moji</a></li>
<li class='menu-sibling'><a href='http://code.jellycan.com/langselect/' target='_top'>LangSelect</a></li>
<li class='menu-expand menu-current'><a href='http://code.jellycan.com/show_menu2/' target='_top'>show_menu2</a>
<ul><li class='menu-child'><a href='http://code.jellycan.com/sm2test/' target='_top'>Test</a></li></ul>
</li>
<li class='menu-sibling'><a href='http://code.jellycan.com/macros/' target='_top'>Macros</a></li>
<li class='menu-sibling'><a href='http://code.jellycan.com/comments/' target='_top'>Comments</a></li>
</ul>
</div>
<li class='menu-sibling'><a href='http://code.jellycan.com/comments/' class='comments'>Comments</a></li>
"<a href='[url]' target='[target]' class='[menu_title]'>[menu_title]</a>"
In my case all I originally wanted to have a different top level icon and color for each top level category
Graphics (paint_brush.gif)
News (newspaper.gif)
I guess that -to create a normal menu- you put a regular php-call of show_menu2
in the index(.)php file, which will create the menu call on every page of your site
... but...
I want a sitemap to be shown only on a single page :|
- How can I do that?
- Wich release of the snippet do I at least nee?
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_DESCKEY,
'<span class="stuff">[a][page_title][/a] (menu: [a][menu_title][/a])'.
'<br /><i>[description]</i><br />([keywords])</span>',
"<ul class='sitemap'>",'</ul>','<li>','</li>',false,false);
Instead of wysiwyg, choose Code for the page type.
Then write the call to show_menu2 directly into the page.
Parse error: parse error, unexpected T_STRING
in /home/httpd/vhosts/mydomain.com/httpdocs/modules/code/view.php(30) : eval()'d
code on line 5
<?php
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_DESCKEY,
'<span class="stuff">[a][page_title][/a] (menu: [a][menu_title][/a])'.
'<br /><i>[description]</i><br />([keywords])</span>',
"<ul class='sitemap'>",'</ul>','<li>','</li>',false,false);
?>
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_DESCKEY,
'<span class="stuff">[a][page_title][/a] (menu: [a][menu_title][/a])'.
'<br /><i>[description]</i><br />([keywords])</span>',
"<ul class='sitemap'>",'</ul>','<li>','</li>',false,false);
<
class='menu-top
'>< class='
menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
menu-expand menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])<
class='
'>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
menu-expand'>[page_title] (menu: [menu_title])
[description]
([keywords])<
class='
'>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>>>>>< class='
menu-expand menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])<
class='
'>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>>>< class='
menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
menu-expand menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])<
class='
'>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>>>< class='
menu-expand menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])<
class='
'>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
menu-expand'>[page_title] (menu: [menu_title])
[description]
([keywords])<
class='
'>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>>>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>>>< class='
menu-expand menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])<
class='
'>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>>>< class='
menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
menu-expand menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])<
class='
'>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>>>< class='
menu-expand menu-sibling'>[page_title] (menu: [menu_title])
[description]
([keywords])<
class='
'>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>< class='
'>[page_title] (menu: [menu_title])
[description]
([keywords])>>>< class='
menu-current'>[page_title] (menu: [menu_title])
[description]
([keywords])>>
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_DESCKEY, '<span class="stuff">[a][page_title][/a] (menu: [a][menu_title][/a])<br /><i>[description]</i><br />([keywords])</span>',"<ul class='sitemap'>",'</ul>','<li>','</li>',false,false);
echo <<<FOO
<style type="text/css">
div.left ul, div.left li, div.left span, div.left * {
text-align: left !important;
}
ul.sitemap li {
text-align: left;
padding-top: 0.5em;
}
ul.sitemap .menu-current > span.stuff {
display: block;
background-color: #E0E0FF;
border-right: 2px solid blue;
}
div.left { text-align: left !important; }
</style>
<h1>Sitemap</h1>
<div class="left">
FOO;
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_DESCKEY, '<span class="stuff">[a][page_title][/a] (menu: [a][menu_title][/a])<br /><i>[description]</i><br />([keywords])</span>',"<ul class='sitemap'>",'</ul>','<li>','</li>',false,false);
echo "</div>";
Note that in my stuff the call to show_menu2 is all on one line.... just only because I this? :?
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_DESCKEY|SM2_MULTIMENU, ...
echo "<style> .rootnav span {border-left: solid 1px red; padding: 0 10px;} .rootnav span.first {border-left: none;} </style>";
show_menu2(0, SM2_ROOT, SM2_START, SM2_TRIM|SM2_DESCKEY|SM2_MULTIMENU|SM2_FIRSTLAST, '[a][menu_title][/a]',"<div class='rootnav'>",'</div>','<span>','</span>','',false);
... SM2_MULTIMENU: I don't see the use for this option.
As far as I am concerned you just make multiple calls to show_menu2,
once for each menu number that you want to display...
@virgil
why not just use multiple calls to show_menu2 as above?
Feel free to enlighten me...
Why are you not using the sitemap module? show_menu2 is designed to
(wait for it) show menus. It is flexible enough to be able to abuse it and create
sitemaps, but it isn't the main purpose of the function.
I know... but I am fund of the additional possibilities of the sitemap with
description and keywords, what the original sitemap doesn't offer...
[PAGE_ID] - The page id of the specific page in the sitemap.
[PARENT] - The parent of the page that is currently in the loop.
[LINK] - The link to the specific page within the sitemap.
[PAGE_TITLE] - The title of the page within the sitemap.
[MENU_TITLE] - The title of the page as it is shown witin the menu.
[DESCRIPTION] - The description of the page within the sitemap.
[KEYWORDS] - The keywords that are given for the current page within the sitemap.
[TARGET] - The target to which the page should be opened.
[MODIFIED_WHEN] - The date when the page has been last modified.
[MODIFIED_BY] - The person who made the last modification to the specific page.
I'm not actually stomping on $extra_where_sql, it is left as is in the original state or added to with the 'AND menu = $aMenu' part if required. So by default we get the 'AND menu = $aMenu' added however to select 'all menus' from a multimenu heirarchy I needed to remove the specific call the menu = $aMenu.
... NOT your show_menu2 :oops:
Reason... I want to combine it with melissa's UDM4 capabilities, see...
http://forum.WebsiteBaker.org/index.php/topic,2805.msg18740.html#msg18740
(from Matthias)
"Sitemap v.2.8 supports the following informations wich you easily can use at the place you want."
"I like the show_menu2 because it is fast (only on database request) and flexible for all things that are needed."
(from Brodie)
"If you do want to use it then do the same as above replacing show_menu with
with show_menu2. To use sm2 with UDM see succhi's comment above.
http://forum.WebsiteBaker.org/index.php/topic,2584.msg20067.html#msg20067"
(from Succhi)
"You're quite right about the whole sitemap thing. [...]"
show_menu2(3, SM2_ROOT, SM2_START, SM2_ALL,
' | <span><a href="[url]">[menu_title]</a></span>',
'',
'',
'',
'<span><a href="[url]">[menu_title]</a></span>',
'');
// fix up the menu number to default to the menu number
// of the current page if no menu has been supplied
if ($aMenu == 0) {
$aMenu = $wb->page['menu'] == '' ? 1 : $wb->page['menu'];
}
sm2_mark_children($rgParent, PAGE_ID, 1);
// mark all children of the current page
if (PAGE_ID != 0) {
sm2_mark_children($rgParent, PAGE_ID, 1);
}
I know that search should have no children so lets not even go down the track of marking anything. That's fixed it for me, plus I set all the $wb->page[] settings that might not be set due to PAGE_ID == 0. Added two short snippets so that the root items gets a class of their own.
<div id=menu><ul id=menuList><li><a href="#" name="submenu" class="submenu">Products</a><ul><li><a href="#">All</a></li>
<li><a href="#">CodeCharge</a></li>
<li><a href="#">CodeCharge Studio</a></li>
<li><a href="#">DemoCharge Studio</a></li>
<li><a href="#" name="submenu" class="submenu">Comparison</a><ul><li><a href="#">CodeCharge Studio</a></li>
<li><a href="#">DemoCharge Studio</a></li></ul></li>
</ul></li>
I want to create this kind of list...
But all my tries lead to garbish :)
Anyway to dump the show_menu2 output into an php array or is this to complicated :D
<ul>
<li><a class="drop" href="../menu/index.html">DEMOS<!--[if IE 7]><!--></a><!--<![endif]-->
<table><tr><td>
<ul>
<li><a href="../menu/zero_dollars.html" title="The zero dollar ads page">zero dollars advertising page</a></li>
<li><a href="../menu/embed.html" title="Wrapping text around images">wrapping text around images</a></li>
<li><a href="../menu/form.html" title="Styling forms">styled form</a></li>
<li><a href="../menu/nodots.html" title="Removing active/focus borders">active focus</a></li>
<li><a class="drop" href="../menu/hover_click.html" title="Hover/click with no active/focus borders">hover/click with no borders
<!--[if IE 7]><!--></a><!--<![endif]-->
<table><tr><td>
<ul>
<li><a href="../menu/form.html" title="Styling forms">styled form</a></li>
<li><a href="../menu/nodots.html" title="Removing active/focus borders">removing active/focus borders</a></li>
<li><a href="#nogo">FLYOUT third level »<!--[if IE 7]><!--></a><!--<![endif]-->
<table><tr><td>
<ul>
<li><a href="#nogo">Third level-1</a></li>
<li><a href="#nogo">Third level-2</a></li>
<li><a href="#nogo">Third level-3</a></li>
<li><a href="#nogo">Third level-4</a></li>
</ul>
</td></tr></table>
<!--[if lte IE 6]></a><![endif]-->
</li>
<li><a href="../menu/hover_click.html" title="Hover/click with no active/focus borders">hover/click</a></li>
</ul>
</td></tr></table>
<!--[if lte IE 6]></a><![endif]-->
</li>
<li class="upone"><a href="../menu/shadow_boxing.html" title="Multi-position drop shadow">shadow boxing</a></li>
<li><a href="../menu/old_master.html" title="Image Map for detailed information">image map for detailed information</a></li>
<li><a href="../menu/bodies.html" title="fun with background images">fun with background images</a></li>
<li><a href="../menu/fade_scroll.html" title="fade-out scrolling">fade scrolling</a></li>
<li><a href="../menu/em_images.html" title="em size images compared">em image sizes compared</a></li>
</ul>
</td></tr></table>
<!--[if lte IE 6]></a><![endif]-->
</li>
<td width="100%" style="height: 173px">
<?php if(SHOW_MENU) { /* Only shown menu if we need to */ ?>
<?php show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, false, "\n</li>", false, false, false, '<ul class="udm" id="udm">'); ?>
<?php } ?></td>
See the UDM website linked from that demo for details of how to set it up. My demo page is just showing that it can be used with sm2. http://www.udm4.com/
B
<div class="root">
<?php show_menu2(0, SM2_ROOT, SM2_START); ?>
</div>
<div class="second-menu">
<?php show_menu2(0, SM2_ROOT+1, SM2_START); ?>
</div>
<?php show_menu2(0, SM2_ROOT, SM2_START, SM2_PRETTY, '[li]<a href="[url]">[menu_title]</a>'); ?>
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?
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. ;)
#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;
}
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
Sure this is correct? Pages available to registered users only will appear in the menu only to registered users.
B
Page Type | Menu Visibility | Page Visibility | Search Results |
Public | Everyone | Everyone | True |
Registered | Everyone *1 (or) Logged in user in correct group *2 | Logged in user in correct group | True |
Private | Logged in user in correct group | Logged in user in correct group | True |
Hidden | Never | Everyone, but only if they know the page URL | True |
None | Never | Everyone, but only if they know the page URL | False |
<?php show_menu2(); ?>
#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 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 li.menu-current 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-c1.gif);
background-position: 13px 5px;
background-repeat: no-repeat;
background-color: #FAF9D0;
}
#menu li 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 li li.menu-current a {
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;
}
<div id="menu">
<ul class="menu-top">
<li class="menu-sibling menu-first"><a href="#" target="_top">Home</a></li>
<li class="menu-expand menu-current"><a href="#" target="_top">Services</a>
<ul class="">
<li class="menu-child menu-first"><a href="#" target="_top">Pricing Guide</a></li>
<li class="menu-child menu-last"><a href="#" target="_top">Hosting Plans</a></li>
</ul></li>
<li class="menu-sibling"><a href="#" target="_top">Portfolio</a></li>
<li class="menu-expand menu-sibling"><a href="#" target="_top">About Us</a></li>
<li class="menu-sibling"><a href="#" target="_top">Contact Us</a></li>
<li class="menu-sibling"><a href="#" target="_top">Site Map</a></li>
<li class="menu-sibling menu-last"><a href="#" target="_top">Members</a></li>
</ul>
if (($page['visibility'] == 'private' || $page['visibility'] == 'registered')
&& false === strstr(",{$page['viewing_groups']},", $currGroup))
{
continue;
}
if ($page['visibility'] == 'private'
&& false === strstr(",{$page['viewing_groups']},", $currGroup))
{
continue;
}
1) show_menu2(0, SM2_ROOT+1, SM2_CURR+1);
2) show_menu2(0, SM2_ROOT+1, SM2_CURR+1, SM2_ALL, false, "\n</li>", false, false, false, '<ul class="udm" id="udm">');
show_menu2(0, SM2_CURR, SM2_CURR, '','- [a][menu_title]</a><br>','','','<br>');
Other pages in the category "XYZ" are:
- sibling
- another sibling
ul
{
margin-left: 0;
padding-left: 0;
list-style: none;
}
li
{
padding-left: 32px;
padding-top: 17px;
background-image: url(zahn_single.png); height: 35px;
background-repeat: no-repeat;
background-position: 0.1em;
}
.menu {
}
.menu a {
font-size: 14px;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #ffffff;
font-weight: bold;
vertical-align: middle;
text-align: left;
text-decoration: none;
background-position:left;
background-repeat:no-repeat;
padding: 2px 0px 2px 2px;
height: 35px;
}
.menu a:hover {
font-size: 14px;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000000;
font-weight: bold;
vertical-align: middle;
text-align: left;
text-decoration: none;
background-repeat : repeat-y;
background : url(menu_hover.png) repeat-y left;
}
// Site Map Menu Call
show_menu2(0, SM2_CURR+1, SM2_CURR+1, SM2_ALL|SM2_ALLINFO, '[li][a][page_title]</a> <br /><blockquote class="highlight">[description]</blockquote>', false, '<ul class="sitemap [class]">');
[description=UNKNOWN]
using another template
show_menu2(0, SM2_ROOT, SM2_MAX+2, SM2_CRUMB, ' > [a][menu_title]</a>', '', '', '', '<strong>You are here:</strong> [a][menu_title]</a>');
I'm using the following to show a site map for current level pages complete with descriptions:
... using SM2_ALLINFO ...
... but when I try using another template it only returns.
[description=UNKNOWN]
<select name="drop_menu">
<?php show_menu2(0, SM2_ROOT, SM2_START, '<option value="[menu_title]">[a][menu_title]</a>', '</option>'); ?>
</select>
http://forum.WebsiteBaker.org/index.php/topic,5730.msg37501.html#msg37501
Is it a big deal to make $aItemClose and $aMenuClose as format strings like $ItemOpen and $aMenuOpen ?
<?php show_menu2(0, SM2_ROOT, SM2_CURR+1, '','[if(class!=menu){[a][menu_title]</a>}]','','',''); ?>
Probably what you want. Lifted verbatim from the examples site:
http://code.jellycan.com/sm2test/
Root Level Only
show_menu2(0, SM2_ROOT, SM2_START);
Children/Siblings
This is often used when splitting menus between the root menu and a side menu showing the children of the current page. This menu will show all of the children of the current top level menu, but will continue to display the siblings of child pages as well when a lower level menu is selected.
show_menu2(0, SM2_ROOT+1, SM2_CURR+1);
Probably what you do NOT want. Anything that has [if...] embedded in it.
Have fun.
show_menu2(0, SM2_ROOT+1, SM2_CURR+1)
... just like you said but I only get the children to show in the left side menu not at the top like I want them.<?php show_menu2(0, SM2_ROOT, SM2_START,
'<ul>' , '<li class="menu">[a][menu_title]</a>', '</li>' , '</ul>', '', ''); ?>
I've tried many combinations of the code but I can't find the right one.
I have the following:
Topic 1
- Sub Topic 1a
- Sub Topic 1b
- Sub sub Topic 1ba
Topic 2
- Sub Topic 2a
- Sub Topic 2b
- Sub sub Topic 2ba
- Sub sub Topic 2bb
What I want is:
When you are in one of Topic 1's Children (Sub Topic 1a, - Sub Topic 1b or Sub sub Topic 1ba) then I want the menu to show all of the children of 1.
When you are in one of Topic 2's Children (Sub Topic 2a, - Sub Topic 2b, Sub sub Topic 2ba or Sub sub Topic 2bb) then I want the menu to show all of the children of 2.
The result has to be that there are 2 menu's: one with all the children (and sub children) of Topic 1 and one with all the Children (and sub children) of Topic 2.
I hope that someone know what I mean and have an answer! :-D
read the documentation of show menu 2 and make the relevant page_ids the starting point.
show_menu2(0, 1, SM2_ALL, SM2_ALL);
I can replace the second number (=1) with the number of the root. But how can I change this number when the menu is changing?Easiest way ... make 2 menu's (look for multiple menu in forum). Use standard menu call in template, just calling the menu numbers.
<div id="navigation">
<?php show_menu2(0, SM2_ROOT, SM2_START);?>
</div>
Subnavigation: <div id="rechtespalte">
<?php show_menu2(1,SM2_ROOT+1, SM2_START);?>
</div>
Service navigation: <div id="metanav">
<?php show_menu2(2, 19, SM2_ALL, SM2_ALL);?>
</div>
My info.php says: $menu[1]='Hauptnavigation';
$menu[2]='Subnavigation';
$menu[3]='Metanavigation';
and multiple menus is enabled in the admin.$menu[0]='Hauptnavigation';
$menu[1]='Subnavigation';
$menu[2]='Metanavigation';
in the info.php with the same negative results.If I understand you correctly, you want to have
1) root level menu
2) child menu
3) an unrelated utility menu.
In this case I would dispense with the whole multiple menu mess, and instead create your menu as normal. In this menu, add a top level hidden item "Utility Menu" and then add all of the utility menu items underneath it. Then make the 3rd call to show_menu2 using that hidden menu item as the root.
i.e. See the sample page at http://code.jellycan.com/sm2test/
These are your menus.
1. Root Level Only
2. Children/Siblings
3. Hidden Menu
B
This menu won't show normally because of the invisible parent. However, you can show it in your template where-ever you want by specifying the ID of the invisible parent:
<?php show_menu2(1, **INVISIBLE_PAGE_ID**, SM2_ALL, SM2_ALL); ?>
<?php show_menu2(0, SM2_ROOT, SM2_CURR+1, SM2_PRETTY, '[list][li]<a href="[url]">[menu_title]</a>'); ?>
else if ($aFlags & SM2_TRIM) {
// parents and siblings of parents
// Always show the siblings
if (!array_key_exists('sm2_is_sibling', $page)
&& !array_key_exists('sm2_on_curr_path', $page) // not set if false, so existence = true
&& !array_key_exists('sm2_path_sibling', $page)) { // not set if false, so existence = true
continue;
}
}
<input type="hidden" name="referrer" value="[REFERRER_ID]" />
<input type="hidden" name="referrer" value="<?php echo defined('REFERRER_ID')?REFERRER_ID:PAGE_ID;?>" />
show_menu2 error: no flags from group 1 supplied! Exactly one flag is required!
<ul class="menu-top">
<li class="menu-sibling menu-first">...</li>
<li class="menu-expand menu-current menu-last">...
<ul class="">
<li class="menu-child menu-first menu-last">...</li>
</ul>
</li>
</ul>
The class in the child-menu ul is empty.Hello,
just released show_menu2 version 4.60 which includes the page_id = 0 bug fix from Brofield on the addons repository (http://addons.WebsiteBaker.org/pages/modules/code-snippets.php).
If your menu disappears after submitting a search, follow the steps below (requires show_menu2 v4.60 or higher)
Step 1: Add the following input field to the database search settings after
the <form> open tag: WB Backend -> Settings -> Show advanced settings -> Search Settings -> HeaderCode: [Select]<input type="hidden" name="referrer" value="[REFERRER_ID]" />
Step 2: In the index.php of your template, add the following input field immediately following the search <form> open tag.Code: [Select]<input type="hidden" name="referrer" value="<?php echo defined('REFERRER_ID')?REFERRER_ID:PAGE_ID;?>" />
Brofield thanks for this bugfix.
Regards Christian
show_menu2(1, SM2_ROOT, SM2_ALL, SM2_TRIM|SM2_PRETTY);
Nothing exotic - did I miss something?Manually install it.
take a copy of the existing modules/show_menu2 directory
delete all of the files
unzip the show_menu2.zip file
copy all of the files into the modules/show_menu2 directory
B
echo'<h3>Categories</h3>';
echo'<div style="border-width:0px;">';
show_menu2(0, SM2_CURR+1, SM2_ALL, SM2_ALL|SM2_CURRTREE);
echo'</div>';
[DESCRIPTION]
show_menu2(0, SM2_CURR+1, SM2_ALL, SM2_ALL|SM2_CURRTREE|SM2_ALLINFO);
The lack of classes on the ul tag is normal. It has always been this.Funny, I never noticed this before ... :roll:
<td id="nav"><?php show_menu2(
$aMenu = 0,
$aStart = SM2_ROOT,
$aMaxLevel = SM2_ALL,
$aFlags = SM2_ALL,
$aItemOpen = '<li class="[menu_title] [class] lev[level]">[a][menu_title]</a>',
$aItemClose = '</li>',
$aMenuOpen = '[ul]',
$aMenuClose = '</ul>',
$aTopItemOpen = false,
$aTopMenuOpen = false
); ?></td>
#nav li {
display: inline;
position: relative;
}
#nav ul li.lev0 {
padding-left: 10px;
padding-right: 10px;
}
#nav li.menu-current {
background-color: #C0C0C0;
}
#nav li:hover {
background-color: #C0C0C0;
}
#nav a {
color: black;
text-decoration: none;
}
.1 {
vertical-align: middle;
}
#nav ul li {
position: relative;
}
#nav ul ul {
display: none;
position: absolute;
}
#nav ul ul ul {
display: none;
position: absolute;
left: 100%;
top: 0;
width: 100%;
}
#nav ul ul,
#nav ul li:hover ul ul,
#nav ul ul li:hover ul ul
{display: none;}
#nav ul li:hover ul,
#nav ul ul li:hover ul,
#nav ul ul ul li:hover ul
{display: block;}
#nav ul li:hover ul {
display: block;
font-size: small;
/*border: 1px solid black;*/
background-color: #C0C0C0;
width: 90px;
filter: Alpha(Opacity=70, FinishOpacity=75, Style=1, StartX=1, StartY=1, FinishX=20, FinishY=20);
opacity: 0.7;
moz-opacity: 0.7;
}
#nav ul ul li:hover ul {
display: block;
position: absolute;
/*left: 600px;
top: 0;*/
/*left: 195%;*/
/*margin-top: -30px;
margin-right: -100px;*/
font-size: small;
/*border: 1px solid black;*/
background-color: #C0C0C0;
width: 90px;
filter: Alpha(Opacity=90, FinishOpacity=95, Style=1, StartX=1, StartY=1, FinishX=20, FinishY=20);
opacity: 0.9;
moz-opacity: 0.9;
}
#nav ul li.About:hover ul {
left: 0px;
margin-top: 28px;
}
#nav ul li.Studio:hover ul {
left: 0px;
margin-top: 28px;
}
#nav ul ul li.Classes:hover ul {
left: 90px;
margin-top: 0px;
}
#nav ul ul li.Calendar:hover ul {
left: 90px;
margin-top: 0px;
}
#nav ul ul li {
list-style: none;
background-image: none;
}
#nav ul ul li:hover {
background-color: #FFFFFF;
}
#nav ul ul li a {
border-top: 1px solid #C0C0C0;
border-bottom: 1px solid #C0C0C0;
text-indent: -40px;
text-align: left;
list-style: none;
background-image: none;
display: block;
}
#nav ul ul li a:hover {
background-color: #FFFFFF;
border-top: 1px solid #990000;
border-bottom: 1px solid #990000;
margin-left: -40px;
text-indent: 0px;
display: block;
filter: Alpha(Opacity=120, FinishOpacity=125, Style=1, StartX=1, StartY=1, FinishX=20, FinishY=20);
opacity: 1.2;
moz-opacity: 1.2;}
#nav ul li.menu-expand {
background-image: url(http://fladance.org/beta/media/down-arrow-sm.png);
background-repeat: no-repeat;
background-position: right;
}
#nav ul ul li.menu-expand {
background-image: url(http://fladance.org/beta/media/right-arrow.gif);
background-repeat: no-repeat;
background-position: right;
}
show_menu2(
$aMenu = 0,
$aStart = SM2_CURR+1,
$aMaxLevel = SM2_ALL,
$aFlags = SM2_ALLINFO|SM2_PRETTY,
$aItemOpen = '<li class="[class] button[page_id]"><a href="[url]" target="[target]" [if(level==0){class="topitem"}][if(level==1){class="subitem[page_id]"}]>[menu_title]',
$aItemClose = '</a></li>',
$aMenuOpen = '<ul>',
$aMenuClose = '</ul>',
$aTopItemOpen = false,
$aTopMenuOpen = false
);
<style type="text/css">.button167 .subitem167{font-weight: bold}</style>
$menu[1] = 'Meny_ovre';
$menu[2] = 'Meny_undre';
<?php show_menu2(1,SM2_ROOT+1,SM2_START+1 ); ?>
<?php show_menu2(2, SM2_CURR ); ?>
SE <- Menulink to "PageSE1"
-PageSE1 <- Assigned to $menu[1]
-PageSE2 <- Assigned to $menu[2]
--PageSE2:1 <- Assigned to $menu[2]
GB <- Menulink to "PageGB1"
-PageGB1
etc..
<?php show_menu2(2,SM2_ROOT+1,SM2_START+1,SM2_ALL|SM2_NOCACHE ); ?>
<?php show_menu2(2,5 ); ?>
But then the EN part doesn´t work :-), but i think som PHP can take care of that...I've always felt that the multiply rooted menu is the best way to implement multiple menus.Do you mean that every menu shall be rooted from level 0 (zero)?
The multiple menu code is only barely tested because I really don't see the point in it.
<div id="menu">
<?php show_menu2(1,SM2_ROOT, SM2_START) ?>
</div>
show_menu2(0, SM2_ROOT, SM2_START, SM2_ALL, ' | [a][menu_title]</a>', '', '', '', '[a][menu_title]</a>');
show_menu2(0, SM2_ROOT, SM2_START, SM2_ALL, ' | [a][menu_title]</a>', '', '', '', '[a][menu_title]</a>', '');
<div id="nav">
<?php show_menu2(0, SM2_ROOT, SM2_ALL, ( SM2_ALL | SM2_NUMCLASS), '<li><a href="[url]" class="[class] navlev[level]">[menu_title]</a>', "</li>", '<ul class="ullev[level]">', "</ul>", true, '<ul id="header_menu" class="menu">');
//show_menu2(0, SM2_ROOT, SM2_ALL, ( SM2_ALL | SM2_NUMCLASS), false, "\n</li>", false, false, false, '<ul id="header_menu" class="menu">'); ?><br style="clear:left;"/>
</div><!-- end nav -->
... show_menu2 is great, but not very easy to use. So, I thought about something like a backend, or even a "code generator". You may think of it as a "Wizard" where you make some choices an get the correct SM2 code to use.
Would that be something of interest?
show_menu2(2, SM2_ROOT, SM2_START, SM2_ALL,'<a href="[url]" target="[target]" class="home">[menu_title]','</a>','','');
<?php show_menu2(0, SM2_ROOT, SM2_ALL, '<li>[a] [if(id=current){id="current_tab"}] [menu_title] [/a]</li>'); ?>
Having a coding quandry... Have used show_menu2 with alot of sites. But this time a customer haded over a template that is very convoluded and complex. And the css is damned near unreadable.
HistoryWhile this was declared as a Bug, I used it as a Feature - several times.
4.8 (8 Apr 2009)
Fixed output of menu when a hidden page is the current or parent page.
$options = array('flags' => SM2_TRIM, 'notrim' => 1);
show_menu2(
$aMenu = 0,
$aStart = SM2_CURR+1,
$aMaxLevel = SM2_ALL,
$aFlags = SM2_ALLINFO|SM2_PRETTY,
$aItemOpen = '<li class="[class] button[page_id]"><a href="[url]" target="[target]" [if(level==0){class="topitem"}][if(level==1){class="subitem[page_id]"}]>[menu_title]',
$aItemClose = '</li>',
$aMenuOpen = '</a></li><ul>',
$aMenuClose = '</a></ul>',
$aTopItemOpen = false,
$aTopMenuOpen = false,
$options
);
<?php show_menu2(3, SM2_ROOT+1, SM2_START, SM2_ALL, '[li][a][menu_title]</a>[/li]', '', '', '', false, false); ?>
044 define('SM2_CURRTREE', 0x0400); // bit 10
045 // Begin MOD by ISTeam, Werner von der Decken, 08.2009
046 define('SM2_HIDEPAGES', 0x0800); // bit 11 (reactivate old behavior and dosn't show hidden pages)
047 // END MOD ---
048 define('_SM2_GROUP_1', 0x000F); // exactly one flag from group 1 is required
.
.
.
574 // mark our current page as being on the current path
575 if ($page['page_id'] == $CURR_PAGE_ID) {
576 $page['sm2_is_curr'] = true;
577 $page['sm2_on_curr_path'] = true;
578 // Begin MOD by ISTeam, Werner von der Decken, 08.2009
579 if (($flags & SM2_HIDEPAGES) == 0){
580 unset($page['sm2_hide']); // don't hide the current page
581 }
582 // END MOD ---
583 }
define('SM2_SHOWHIDDEN', 0x0800); // bit 11 (set to show hidden pages)
… …
$page['sm2_is_curr'] = true;
$page['sm2_on_curr_path'] = true;
if (($flags & SM2_SHOWHIDDEN) != 0){
unset($page['sm2_hide']); // don't hide the current page
}
If that is the case, than rather than adding a new option, the current change should be backed out.
<?php
show_menu2(0, SM_ROOT, SMROOT+1, SM2_ALL | SM2_PRETTY, ....