WebsiteBaker Support (2.8.x) > Templates, Menus & Design

show_menu2 question

(1/3) > >>

jschor:
I use the show_menu2 function in one of my sites. I copied this from the All CSS2 template and altered the css slightly.

<?php show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, false, "\n</li>", false, false, false, '<ul id="header_menu" class="menu">'); ?>

I works fine. Now i have a question. Is it possibel to have the 1st level only clickable when there are no sublevels. And not clickable when there are sublevels.

See http://195.238.74.250/~amstel/wb/

so home must be clickable and there is a home.php and eten & drinken is not clickable, only the sublevels.

I hope you understand my question.

Funky_MF:
Of course, there is a way to have the 1st level only clickable when there are no sublevels and so on.. e.g. with an additional command that gives no <a>-Tag to the Link-Title. But I think, for using the hover-effect in IE, it is recommended to use the <a> -Tag, otherwise the hover-effect is not working correctly.

An alternative way: Make a Menulink for the Firstlevel-Link and set it to the first Page in the Menu.

jschor:
Thanx for your reply.
I only wonder if this can be done with the different options of the show_menu2. For example the conditional formatting. But reading this i don't understand all the options and how to implement them.

CONDITIONAL FORMATTING
======================
The conditional formatting directive takes the following form:

    [if(ABC){D}]
   
    A   Left operand. It must be one of the following keywords:
            class       Test for existence of one of the classes. Only the
                        "==" and "!=" operators are permitted. In this case
                        these operators have the meaning of "includes"
                        instead of "equals".
            level       Test against the page level.
            sib         Test against the current page sibling number.
            sibCount    Test against the number of siblings in the menu.
            id          Test against the page id.
   
    B   Operator. It must be one of the following:
            <           Less Than
            <=          Less Than Equals
            ==          Equals
            !=          Not Equal
            >=          Greater Than Equals
            >           Greater Than
   
    C   Right operand. The type of this operand depends on the keyword used
        for the left operand:
            class       One of the "menu-*" class names as listed in the
                        section "OUTPUT".
            level       Test the page level against the following values:
                          <number>  absolute page level
                          root      the root page level
                          granny    the grand-parent page level
                          parent    the parent page level
                          current   the current page level
                          child     the child page level
            id          Test the page id against the following values:
                          <number>  absolute page id
                          parent    the parent page id
                          current   the current page id
            sib         A positive integer, or "sibCount" to test against
                        the count of siblings in this menu.
            sibCount    A positive integer.
           
    D   Expression. This may be any string that does NOT include the '}' character.
        It may include any of the format strings described in the section FORMAT
        STRINGS with the exception of the conditional test (because the '}'
        character is not permitted).
   
NOTE: with the exception of D (Expression), NO WHITESPACE IS PERMITTED within
the directive. It must take the exact form as given above.

For example, the expression "exp" is emitted only when the menu item:
   
    [if(class==menu-expand){exp}]   has a sub-menu
    [if(class==menu-first){exp}]    is first item in a menu
    [if(class!=menu-first){exp}]    is NOT first item in a menu
    [if(class==menu-last){exp}]     is last item in a menu
    [if(level==0){exp}]             is at the root
    [if(level>0){exp}]              is not at the root
    [if(sib==2){exp}]               is the second item in a menu
    [if(sibCount>1){exp}]           is in a menu with more than 1 entry
    [if(sibCount!=2){exp}]          is in a menu which doesn't have exactly
    [if(level>parent){exp}]         is in a sibling menu or child of a sibling
    [if(id==parent){exp}]           is the parent of the current page

doc:
Hello,

have you already tried to play with the following example from the tutorial you´ve posted?

--- Code: ---[if(class==menu-expand){exp}]   has a sub-menu
--- End code ---
{exp} should be replaced according to your needs

Regards Christian

Funky_MF:
Hi jschor,

try this:
--- Code: ---<?php show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, &#39;[if(class!=menu-expand){[li][a][menu_title]</a>}][if(class==menu-expand){[li][menu_title]}]&#39;, "\n</li>", false, false, false, &#39;<ul id="header_menu" class="menu">&#39;); ?>
--- End code ---

It's not tested, but it should work.

Navigation

[0] Message Index

[#] Next page

Go to full version