WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: viiksi on October 19, 2010, 01:57:29 PM

Title: Menu with one step without links
Post by: viiksi on October 19, 2010, 01:57:29 PM
Hello,

Heres a little explaining.

root
-level1
-level1
---level2 (Not link)
-----level3
---level2 (Not link)
-----level3
-----level3
-level1

Heres what i have at the moment.
<?php show_menu2(0, SM2_ROOT+1, SM2_ALL, SM2_ALL, false,"\n</li>", false, false, false, '<ul id="header_menu" class="menu">'); ?>

In this i make links that starts from level1. (root level shows elsewhere)
What i want is Level2 to be only text and not linkable row but still should open Level3 onmouseover. And of course level3 should be links again ;)

Not sure if i explained this easy enough ;)

Could there be some css code that would make level2 not linking to that page.

 - viiksi
Title: Re: Menu with one step without links
Post by: Stefek on October 19, 2010, 02:07:44 PM
You can use just sm2 for this.

See documentation and the topic on conditionals
Pseudocode: [if level=n {nolink} else {link} ]

Regards,
Stefek
Title: Re: Menu with one step without links
Post by: viiksi on October 19, 2010, 02:22:31 PM
Thanks for fast answer.

I read the documentation many times allready even before this ;)
But in that document there is no {nolink} option at all.

i still dont get it where in that line to put your code.

 - viiksi

Title: Re: Menu with one step without links
Post by: Stefek on October 19, 2010, 02:43:56 PM
it was just a "pseudo code".

Please read the opic on conditionals, as I said before:
http://code.google.com/p/showmenu2/source/browse/tags/4.9/README.en.txt#463

What you'll need is something like

...
      $aItemOpen      = '[if level=2 {<li>[menu_title]} else {<li>[a][menu_title]</a>}]',
...


Regards,
Stefek
Title: Re: Menu with one step without links
Post by: DarkViper on October 19, 2010, 03:03:03 PM
...
      $aItemOpen      = '[if level=2 {<li>[menu_title]} else {<li>[a][menu_title]</a>}]',
...


this solution is ok. But unfortunately  hardcoded to a special level. Softcoded it can look like that:
Code: [Select]
     $aItemOpen =>>    '[if target==_self {<li>[menu_title]} else {<li>[a][menu_title]</a>}]',

it's a bit tricky use of Target. For 'normal' pages you can use the target '_top' for 'break frameset' and '_blank' for an external link. If you choose '_self' so the menu_title is displayed without a link.

ps @stefek:: compare by  == instead of = then it works..  :wink:
Title: Re: Menu with one step without links
Post by: viiksi on October 19, 2010, 03:13:55 PM
it was just a "pseudo code".

I really have to confess that i had to use wikipedia even to check what "pseudo code" means ;)

As you might notice now im not good at coding.

But yes now we are on right track.

I will bang my head to wall tonight to get this work.

 ps. For this solution hardcoded works very well since its never going to be changed afterwards.

 - viiksi
Title: Re: Menu with one step without links
Post by: Stefek on October 19, 2010, 03:18:53 PM
it's a bit tricky use of Target. For 'normal' pages you can use the target '_top' for 'break frameset' and '_blank' for an external link. If you choose '_self' so the menu_title is displayed without a link.
Too confusing..
It's the same as using  Keywords for unique titles in the menu ;-)

ps @stefek:: compare by  == instead of = then it works..  :wink:
Of course, just on the fly, no testing..

Regards,
Stefek
Title: Re: Menu with one step without links
Post by: viiksi on October 19, 2010, 11:24:29 PM
Well thanks for you both.
I know finally understand what those false words even means on that code ;)

It was good that you didnt tell me right solution straightaway so i had to think.

I had to do some modification to the code so it started to work.

...
      $aItemOpen      = '[if level=2 {<li>[menu_title]} else {<li>[a][menu_title]</a>}]',
...


to '[if(level=2) {<...
Title: Re: Menu with one step without links
Post by: Stefek on October 19, 2010, 11:37:17 PM
It was good that you didnt tell me right solution straightaway so i had to think.

Yes great,
mostly like people using their own brains  :wink:

Glad you got it working.

Regards,
Stefek
Title: Re: Menu with one step without links
Post by: davidwaterman on February 16, 2011, 10:04:28 AM
Hi Guy's I'm trying to do the same. But get code printing to the screen. Would you tell me what i'm doing wrong please?

      <?php show_menu2(1, SM2_ROOT, SM2_ALL, SM2_ALL, '[iflevel=1{<li>[menu_title]}else{<li>[a][menu_title]</a>}]', "\n</li>", false, false, false, '<ul id="header_menu" class="menu">'); ?>

Thanks in advance.
Title: Re: Menu with one step without links
Post by: daydreamer on February 13, 2014, 12:16:48 PM
I just can't seem to get this working.

I'm replacing

Code: [Select]
$aItemOpen      = false,
with

Code: [Select]
$aItemOpen      = '[if level=2 {<li>[menu_title]} else {<li>[a][menu_title]</a>}]',
But does not work. Am I doing something wrong?


Thanks
Title: Re: Menu with one step without links
Post by: jacobi22 on February 13, 2014, 12:34:50 PM
missing the () arround the question  -> if (level=2)
Code: [Select]
$aItemOpen      = '[if (level=2) {<li>[menu_title]} else {<li>[a][menu_title]</a>}]',
Title: Re: Menu with one step without links
Post by: daydreamer on February 13, 2014, 01:10:48 PM
Thanks but still does nothing at all  :?
Title: Re: Menu with one step without links
Post by: daydreamer on February 13, 2014, 01:12:34 PM
Is it right adding it in modules/showmenu2.includes.php ?
Title: Re: Menu with one step without links
Post by: jacobi22 on February 13, 2014, 01:24:49 PM
Is it right adding it in modules/showmenu2.includes.php ?
no, thats a part from the show_menu2() call in your template index.php

as eample from my actual project
this show_menu2 remove the URL and set only a #, if this menu point has subpages - [if(class==menu-expand)
and it set the class "down" for all menu points in the first level  [if(level=1){down}]


Code: [Select]
<?php show_menu2(
                        
$aMenu          1,
                        
$aStart         SM2_ROOT+1,
                        
$aMaxLevel      SM2_ALL,
                        
$aOptions       SM2_ALL|SM2_CURRTREE|SM2_PRETTY,
                        
$aItemOpen      '<li class="[class]"><a href="[if(class==menu-expand){#}][if(class!=menu-expand){[url]}]" class="[class] p[page_id] [if(level=1){down}]" title="[menu_title]">[menu_title]</a>',
                        
$aItemClose     '</li>',
                        
$aMenuOpen      '<ul>',
                        
$aMenuClose     '</ul>',
                        
$aTopItemOpen   false,
                        
$aTopMenuOpen   '<ul class="nav" id="dropline">'
        
); ?>
Title: Re: Menu with one step without links
Post by: daydreamer on February 13, 2014, 03:23:34 PM
I'm no coder at all, I am using this in my template index.php

Code: [Select]
<?php show_menu2(1SM2_ROOTSM2_ALLSM2_ALL|SM2_NUMCLASS|SM2_PRETTYfalsefalse); ?>
Title: Re: Menu with one step without links
Post by: jacobi22 on February 13, 2014, 05:46:29 PM
try this

shoes no Links in Level 2, only the menu_title
(remember , WB starts in LEVEL 0 (zero)

Code: [Select]
<?php show_menu2(
                        
$aMenu          1,
                        
$aStart         SM2_ROOT,
                        
$aMaxLevel      SM2_ALL,
                        
$aOptions       SM2_ALL|SM2_NUMCLASS|SM2_PRETTY,
                        
$aItemOpen      '<li class="[class]"><a href="[if (level=2) {<li>[menu_title]} else {<li>[a][menu_title]</a>}]'" title="[menu_title]">[menu_title]</a>',
                        
$aItemClose     = '</li>',
                        
$aMenuOpen      = '<ul>',
                        
$aMenuClose     = '</ul>',
                        
$aTopItemOpen   = false,
                        
$aTopMenuOpen   = '<ul>'
        ); ?>

if you need Level 0 or Level 1 without Links, change the Line $aItemOpen  at this point -> if (level=2)
Title: Re: Menu with one step without links
Post by: daydreamer on February 14, 2014, 11:38:28 AM
Thanks but that code is throwing an error
Title: Re: Menu with one step without links
Post by: nibz on February 14, 2014, 11:59:25 AM
I think the problem is a little typo.

Try this:
Code: [Select]
<?php show_menu2(
                        
$aMenu          1,
                        
$aStart         SM2_ROOT,
                        
$aMaxLevel      SM2_ALL,
                        
$aOptions       SM2_ALL|SM2_NUMCLASS|SM2_PRETTY,
                        
$aItemOpen      '<li class="[class]"><a href="[if (level=2) {<li>[menu_title]} else {<li>[a][menu_title]</a>}]" title="[menu_title]">[menu_title]</a>',
                        
$aItemClose     '</li>',
                        
$aMenuOpen      '<ul>',
                        
$aMenuClose     '</ul>',
                        
$aTopItemOpen   false,
                        
$aTopMenuOpen   '<ul>'
        
); ?>
Title: Re: Menu with one step without links
Post by: jacobi22 on February 14, 2014, 12:29:52 PM
Thanks but that code is throwing an error
sorry  :oops:
Title: Re: Menu with one step without links
Post by: nibz on February 14, 2014, 01:06:13 PM
Thanks but that code is throwing an error
sorry  :oops:

Can happen to anyone ;)
There was an extra ' after {<li>[a][menu_title]</a>}]'
The code formatting of the forum pointed me to the right direction (your php closing tag was red instead of blue)

Hope with this correction daydreamer has what he/she is looking for.
Title: Re: Menu with one step without links
Post by: jacobi22 on February 14, 2014, 01:16:57 PM
The code formatting of the forum pointed me to the right direction (your php closing tag was red instead of blue)

i copy the code from my project and change it here with daydreamers code from the top - one char to much  :roll:

p.s. thanks for repairing  :-D
Title: Re: Menu with one step without links
Post by: daydreamer on February 14, 2014, 05:14:42 PM
Thanks guys really appreciate this.

Now showing menu like this in my template
Code: [Select]
" title="Home">Home
About
" title="About">About
Contact
" title="Contact">Contact
Why Us
" title="Why Us">Why Us

and links like this
Code: [Select]
http://localhost/%3Cli%3E%3Ca%20href=
Title: Re: Menu with one step without links
Post by: jacobi22 on February 14, 2014, 05:50:45 PM
its testet now  :oops:

Code: [Select]
<?php show_menu2(
                        
$aMenu          1,
                        
$aStart         SM2_ROOT,
                        
$aMaxLevel      SM2_ALL,
                        
$aOptions       SM2_ALL|SM2_NUMCLASS|SM2_PRETTY,
                        
$aItemOpen      '<li class="[class]">[if (level=2){[menu_title]}else{<a href="[url]" class="[class]" title="[menu_title]">[menu_title]</a>}]',
                        
$aItemClose     '</li>',
                        
$aMenuOpen      '<ul>',
                        
$aMenuClose     '</ul>',
                        
$aTopItemOpen   false,
                        
$aTopMenuOpen   '<ul>'
        
); ?>

maybe you dont need the automatic css-class in the li-Tag here <li class="[class]">
feel free to cut this to a simpla <li>
Title: Re: Menu with one step without links
Post by: daydreamer on February 14, 2014, 07:37:12 PM
Thanks so much for your help, works exactly as I need it with

Code: [Select]
$aItemOpen      = '<li><a href="[if(class==menu-expand){#}][if(class!=menu-expand){[url]}]" class="[class] p[page_id] [if(level=1){down}]" title="[menu_title]">[menu_title]</a>',
Title: Re: Menu with one step without links
Post by: jacobi22 on February 14, 2014, 07:48:07 PM
cool  :wink: