show_menu2: valid XHTML and CSS selectable menus

Boudi

Hello,

Recently I noticed a 'bug'? in the show_menu2 function along with the WB search function. When doing a search the menu dissapears. This only happens with multilanguage websites.

Example: go to the HELP page on this WB site and do a search; the vertical menu dissapears after the search. This is the exact problem that I'm facing for the last month when building my own multilanguage website.

See thread: https://forum.WebsiteBaker.org/index.php/topic,9206.msg55182.html#msg55182

My question is if there are more users who are formiliair with this issue? I already notified sir Brofield regarding this behaviour and hope that he can help me/us in this matter.

Sincerley
Knert
...:: Bake the Unbakable ::...

doc

Hello,

thanks to BerndJM, we have now a German README file for the show_menu2() code snippet. The German README_DE is included in the lateste code snippet version v4.50 on the Addons repository.

Bernd, thanks for this contribution, pretty sure many people out there will like it  :-)

Regards Christian

doc

#218
Thanks Brofield,

added your new version to the addons repostiory.

Regards Christian

brofield

A little cleanup and re-release of Thorn's 4.41 version as 4.5. This has support for WB 2.7 (but maintains support for 2.6.7 still). Source repository is now available at http://code.google.com/p/showmenu2/

See http://code.jellycan.com/show_menu2/ for the download.

Tested with 2.6.7 but not with 2.7
Let me know if there are problems with 2.7

brofield

kozmoz ->
How is your menu different to the test site? The following page is a second level menu with children. I don't see the same problem.
http://code.jellycan.com/sm2test/pages/enterprise/cogs-amp-wheels.php

Not saying that you haven't found a bug. Just clarifying.

B

kozmoz

We had a little issue with our menu.

When we displayed a page that was at the second level of the menu, suddenly all of its sibling items disappeared. Opening a child at the third level reveals the menu items again.

Now in the sm2_recurse() function I have added an extra check.
This fixed the bug we had, but I'm not sure if it's done right:

in include.php:

        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;
            }
        }


masarin

#214
Tnx.

Uhh, thats hard reading for a non PHP programmer, but I managed to come up with this that's vaidates as XHTML Strict:

<?php show_menu2(0SM2_ROOTSM2_CURR+1SM2_PRETTY'[list][li]<a href="[url]">[menu_title]</a>'); ?>


I then tried to add some other parameters like "SM2_MAX+1" to limit the menu to two levels (root an one sublevel) but then the whole menu disappeared. So I don't really understand the syntax here, it was just luck.

Guess I have to read the documentation a few times more then..

doc

Hello,

yes this is possible with the show_menu2 code snippet. Please read the documentation of the developer which explains what parameters you need to change (section FORMAT STRINGS).

Regards Christian

masarin

I am making my first WB Template and want it to be valid XHTML Strict.

When validating the template I get the error: there is no attribute "target"

The "<?php show_menu2(); ?>" prints the menu items like this:

<ul class="menu-top">
<li class="menu-sibling menu-first">
<a href="http://mysite/wb" target="_top">Hem</a>
</li>
</ul>

Q:
Is there a way to make show_menu2 print the "<a>" tags without the "target=" attribute?

lanesharon

#211
Brofield,  You might want to remove the references to the udm4 menu, since you are releasing your show_menu2 product as GPL.  udm4, per their website - "is not open-source or public domain software".  Read the rest here:
http://www.udm4.com/licensing/terms/

I have a menu that I use on another website that uses the popout feature.  You may want to look here for it:
http://www.xs4all.nl/~peterned/

brofield

Use the page id. i.e. class="page_[page_id] [class]"

B

deeve007

#209
The breadcrumb code wouldn't show anything. I have show_menu2() working fine, but when using the following code absolutely nothing is displayed:

show_menu2(0, SM2_ROOT, SM2_CURR, SM2_CRUMB, '<span class="[class]"> > [a][menu_title]</a>', '</span>', '', '', '<b>You are here:</b> <span class="[class]">[a][menu_title]</a>');

Anyway, have decided to use echo PAGE_TITLE, very simple, to show where I am.

Next issue: I can't see anywhere that shows it possible to assign a class to each individual menu item, in case you want to use an image for each menu item. Easy to assign a class to a menu level, but is it possible to assign for each actual menu item?

And if not, I would suggest this as a fairly important addition to be made.

brofield

Use show_menu2 to show the breadcrumbs.  Add a link to the top menu manually.
See http://code.jellycan.com/sm2test/pages/oompa.php which is a page of a hidden
utility menu. Then look for "breadcrumbs". Copy and modify the code as necessary.

B

deeve007

Quote from: brofield on March 01, 2006, 03:33:51 AM
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); ?>

Okay, got my utility menu displaying great with this code. Now my issue is with the breadcrumbs, which show the "hidden" parent page of the utility pages.

I'm using show_breadcrumbs() to display the breadcrumbs. Is there any way to have the breadcrumbs show a link to the Homepage followed by the name of the current utility page, but NOT show the hidden utility parent?

Thanks

spida


brofield

It is the page ID for the parent item. Note that this item will not be displayed, only it's children will. You get this number by logging into the admin, clicking on the page that you want to be the parent as though you are going to edit it, and then reading the number out of the address bar.

e.g.
Login
Pages
click page you want as parent
address bar =
http://code.jellycan.com/sm2test/admin/pages/modify.php?page_id=19
The page_id is 19
put this into the show_menu2 call as the parent.

B

spida

Quote from: brofield on September 06, 2007, 06:37:59 PM
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


Hi Brofield,

tx for the explanation. I discarted the multiple menu stuff and now have simply three calls for show_menu2 in the code, just as you suggested.
I actually didn't need to change the calls for the main navigation and the menu with its children. The only thing I still don't understand (despite reading your documentation a couple of times) are the variables you use for the hidden menu:
show_menu2(0, 19, SM2_ALL, SM2_ALL), e.g. what is the 19 referreing to?

This menu is still not displayed, thus I would like to understand how the script works to get it work. :-)

Thank you in advance for some further assistance,
regards,
Ayshe

brofield

Yes. Learn HTML and CSS and go for your life.

First create it yourself in straight HTML. Once you know how to do it,
you then automate it with a menu function like SM2.
See the documentation for what CSS classes SM2 creates.

B

ms

#202
Hi,

I have a difficult question. I want to generate a menue with some graphical elements - different for each level - see here:



The black lines show the different (background)  images.

Is it possible and how can I do this with show_menu2?
Any help would be fine.

Thank You an best wishes

Mathias

brofield

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

spida

Quote from: kweitzel on April 28, 2007, 06:37:24 PM
Easiest way ... make 2 menu's (look for multiple menu in forum). Use standard menu call in template, just calling the menu numbers.

Hi Klaus and all,

I used the search for "multiple menu" but didn't find quite what I am looking for, thus I just ask here:
I have this site with three menus:
1. is the main navigation
2. is the subnavigation of second level pages
3. is supposed to be a service navigation with links to contact page etc.

I have it in index.php like this:
Mainnavigation: <div id="navigation">
            <?php show_menu2(0SM2_ROOTSM2_START);?>
            </div>

Subnavigation: <div id="rechtespalte">
            <?php show_menu2(1,SM2_ROOT+1SM2_START);?>
            </div>

Service navigation: <div id="metanav">
            <?php show_menu2(219SM2_ALLSM2_ALL);?>
            </div>

My info.php says: $menu[1]='Hauptnavigation';
$menu[2]='Subnavigation';
$menu[3]='Metanavigation';

and multiple menus is enabled in the admin.
Main and sub navigation both work properly, but pages I assign "Metanavigation" to in the page's prefernces are simply not shown in any of the menus.

I also tried
$menu[0]='Hauptnavigation';
$menu[1]='Subnavigation';
$menu[2]='Metanavigation';

in the info.php with the same negative results.

The navigations' "physical" order in the html is:
meta navigation first
then main menu
and after that sub menu

... don't know whether this is of relevance.

Obviously I have still not understood the menu2 stuff completely and would some help appreciate very much.

Thanks in advance,
Ayshe

brofield

Version 4.4 now available at http://code.jellycan.com/show_menu2/


  • Support for a new flag, SM2_ESCAPE to turn on HTML escaping of output. Shouldn't be needed, but just in case.
  • Deprecated use of SM2_NOESCAPE and made it the default, since the latest version of WB escapes the strings before adding them to the DB.

brofield

Version 4.3 now available at http://code.jellycan.com/show_menu2/


  • Support for a new flag, SM2_BUFFER. This turns on internal buffering of menu HTML which is then returned from the show_menu2() function allowing easy post processing of the output.
  • Support for a new flag, SM2_CURRTREE. This limits the output to only menu items that exist in the same rooted menu tree as the current page.

See the new examples at the SM2TEST website:
"Tree rooted at parent item" showing use of the SM2_BUFFER flag
"Current Tree Only" showing use of the SM2_CURRTREE flag

http://code.jellycan.com/sm2test/pages/enterprise/cogs-wheels/cogs/little.php

nickleermans: use the SM2_CURRTREE flag as in the example.

B

nickleermans

Quote from: nickleermans on April 28, 2007, 02:20:43 PM
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

This is my original post. And this is an answer:

Quote from: kweitzel on April 28, 2007, 06:37:24 PM
read the documentation of show menu 2 and make the relevant page_ids the starting point.

I found out that with this: 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?

Can anyone find an answer to my original question?

lleighh2

@brofield So sorry for upsetting you or for suggesting that my time was more important than yours. I just don't understand the documentation or the examples and i thought that since everyone else on this thread seems to be getting it and i'm not then i could draw on the collective success of you all. please forgive my faux pas. and thank you so much for your help.

btw. that's exactly what i've had in my css all along. not sure why it's not working. i try not to won't bother you again.