show_menu2: valid XHTML and CSS selectable menus

scottm52

Quote from: scottm52 on May 06, 2009, 10:04:11 PM
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.

When in doubt..  change the code...  I went with the more sturctured call and it made it tons easier to debug...

<?php show_menu2(
    $aMenu          = 0,
    $aStart         = SM2_ROOT,
    $aMaxLevel      = SM2_ALL,
    $aOptions       = SM2_TRIM,
    $aItemOpen      = '<li><a href="[url]" id="[if(id==current){updates_tab}]"> [menu_title] [/a]',
    $aItemClose     = '</li>',
    $aMenuOpen      = '<ul id="tabMenu">',
    $aMenuClose     = '</ul>',
    $aTopItemOpen   = false,
    $aTopMenuOpen   = false
    )
?>


scottm52

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.

But, I have show_menu2 doing it.  Cool.  With a noted exception..  not so cool, and hence the question.

They're governing the highlighting of athe current page with a unique page id  Which I can discover programmatically with SM2 pretty easily.

<?php show_menu2(0SM2_ROOTSM2_ALL'<li>[a] [if(id=current){id="current_tab"}] [menu_title] [/a]</li>'); ?>

Now if you look close that call just won't work.  But how would I set a hard id with an evaluation like this?

THX


brofield

http://code.jellycan.com/sm2test/pages/parent/hidden-kids.php#currchild
This page is a hidden page that has children. Those children are shown correctly, see the test "currchild".

I guess the problem is you use of SM2_ROOT + 1 as the start. SM2 won't traverse through the hidden page to show the children. It doesn't even store information about hidden pages at the moment. It could be fixed to do so, but don't hold you breath waiting.

crnogorac081

 I am not a coder, but based on my experience with WB, SM2 can not see hidden pages, if they are shown in menu, then they are not hidden, right :)))) and if SM2 can not see them, it can not create submenu :P correct me if i m wrong :)
Web developer

vanbemmel

Hi, i use showmenu2 on a site where i display only subitems with this tag:

<?php
show_menu2(
    $aMenu          = 0,
    $aStart         = SM2_ROOT+1,
    $aMaxLevel      = SM2_CURR+1,
    $aOptions       = SM2_TRIM,
    $aItemOpen      = '<a href="[url]" target="[target]" [if(level==1){ class="nav"}][if(level==2){ class="sub"}]>[if(level==2){- }][menu_title]</a>',
    $aItemClose     = '',
    $aMenuOpen      = '',
    $aMenuClose     = '',
    $aTopItemOpen   = false,
    $aTopMenuOpen   = false
    )
?>           

But when you're on a hidden page the subitems of that page are not displayed in the menu either.
When i change the current page to "not hidden" the submenu's are displayed well.\

Is it possible to change this code so submenu's are also displayed on hidden pages ?

Thank you.

Xagone

thanks brofield... but, already tried and missed.

that's why I asked... i think i'll go with php something like this :

if (page language is french) then {show english menu} else {go with french}
Xagone Inc. (formerly VotreEspace)
[url="http://xagone.com/"]http://xagone.com/[/url]

brofield

Easier to just hardcode that sort of menu, but if you really want to do it then show just the top level menu (see "root"). Then add conditional formatting to exclude the current menu item (2).

(1) http://code.jellycan.com/sm2test/#root
(2) http://code.jellycan.com/sm2test/pages/conditional/show-only-siblings.php

Xagone

Nope, doesnt do the trick, thanks for the help.

what i want

when in french, show the menu "english"
when in english, show the menu "french"
Xagone Inc. (formerly VotreEspace)
[url="http://xagone.com/"]http://xagone.com/[/url]

BerndJM

#286
hi Espace,

at a first hint:
your root is french / english that you wont to display
so your startlevel is SM2_ROOT + 1

Hope I understand your question right ....

Regards Bernd
In theory, there is no difference between theory and practice. But, in practice, there is.

Xagone

#285
i've search and cant fond that ...

how can i identify my base root parent ?

i've got 2 languages

in hierarchy

french
-home
-stuff
-- substuff
english
-home
-stuff
-- substuff

how can i do something like "if this menu is my base parent, do not show it" so that when in french, only english shows, and in english only french shows... ?

right now I use :
show_menu2(2, SM2_ROOT, SM2_START, SM2_ALL,'<a href="[url]" target="[target]" class="home">[menu_title]','</a>','','');
Xagone Inc. (formerly VotreEspace)
[url="http://xagone.com/"]http://xagone.com/[/url]

WebBird

I know that site, but I hear very often that people have problems using show_menu2 all the same. (Me, too, though I'm a developer. I took some answers from the module's code, but most people can't do that.)

brofield


virgil

Quote from: WebBird on March 30, 2009, 04:47:44 PM
... 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?

oh yes yes yes, please!  :roll:

so long
virgil
Virgil - the pre-baked-stuff baker -   ;-))

WebBird

Hi,

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?
@brofield: Would you be interested in helping me doing this? :-D I would do the "backend" or "generator", but I'm sure I need help in some cases. :roll:

hexa86

Thanks for your really fast reply. That's real SUPPORT, man. I just took a short look at it, but after work I will check it out in detail, it really looks the way I can use it however.

You made my day.

brofield

I just added this entry to the FAQ. Does that help you?

http://code.jellycan.com/files/show_menu2-README.txt
Q:  How do I use a different class/picture/color/widget for each entry in a menu?

B

hexa86

Hi guys, hi community,

I really appreciate your work on show_menu2, and I just use it while creating a website with website baker but I have one simple question:

I just read your documentation about it, but I was wondering if/how it is possible to address every single generated menu entry for itself. Sorry, if you don't understood me, but English is a foreign language for me :(

Why do I need this? I just want to give every entry a different color with CSS. But I have no clue how to adress the generated entries.

I use the template called "module_finder" and that's my relevant code snippet out of it:

<div id="nav">
           <?php show_menu2(0SM2_ROOTSM2_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 -->


at the moment I only adress all generated entries with #nav in my external css-file, because I do not know how to adress them seperately.

I'd really appreciate your help, and I hope you can tell me whether this is possible or if it is possible a different way. Thank you in advance!

greets
christoph

Peter R

Thanks for the fast response.
I have no idea what the block was doing there. It was in the template I started with.
To be honnest, I don't even knew block excised.

Got it working now.
Thank again!

BerndJM

Hi,

it's 'cause you format the .menu a:link, .menu a:visited, .menu a:active  with display: block in your screen.css

Regards Bernd
In theory, there is no difference between theory and practice. But, in practice, there is.

Peter R

Hello,

I am experiencing something weird problems with show_menu2, and I have no ideas left.
I want to have my menu look like this:
Home | part1 | part2 | part3
For this, I used:
<?php show_menu2(1, SM2_ROOT, SM2_START, SM2_ALL, ' | [a][menu_title]</a>', '', '', '', '[a][menu_title]</a>'); ?>
Just right out of the textbook.
On the site, everything is under eachother?!?
If I look to the HTML, I have I would say it looks oke? If I put the HTML in frontpage, in design mode it is also oke. In preview mode, it is wrong?!?

What am I doing wrong?
You can find it her: www.tintles. nl

Have fun, like i did...

BerndJM

oh, I see the "problem"
but the manual say at this point:

page_id     Display using the specific page as the parent. All
                    child menus of that page will be displayed
.


I have no idea at the moment :|
Maybe you could send a PM to the developer of SM2 ...

Regards Bernd
In theory, there is no difference between theory and practice. But, in practice, there is.

luckyfish


Thanks Bernd - I think I have the syntax correct now.

<?php show_menu2(1, 4, SM2_ALL, SM2_TRIM); ?>

But the only output I can get to display are the children of a specific page (4) - not page_id 4 itself. Is there a way to do that?

Thanks - matt

BerndJM

Hi,

using the page_id as $aStart should work fine, but - as far as I know - you can't use a numeric value for $aMaxLevel. It should be one of the following:
SM2_ALL - SM2_CURR (+N) - SM2_START (+N) - SM2_START (+N)

Regards Bernd
In theory, there is no difference between theory and practice. But, in practice, there is.

luckyfish


Is there a way to display specific root-level pages -and their child pages - and nothing else? For example, say I just want to show the "forum" link above - and no other pages. (The navigation for the site I'm developing is very erratic/inconsistent - so I figured I'd style each nav item individually)

I thought this could be accomplished by putting specific page_ids as the $aStart value. 
<?php show_menu2(1, 4, 0, SM2_TRIM); ?>

But that doesn't seem to work. I searched the forum but couldn't find anything on this specifically.

Any ideas would be very much appreciated.

Thanks, matt