WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: tsb on January 16, 2010, 05:53:14 PM

Title: How do you make the parent menu unclickable? <SOLVED>
Post by: tsb on January 16, 2010, 05:53:14 PM
I got asked this today and tried to figure it out, I found some php coding in drupal, via this, http://drupal.org/node/128618 and theres some code in Joomla.

How do you get it to work in WebsiteBaker?,

Basically, I want the drop down menu that happens in the template allcss2, yet the top, parent is not a clickable link and is basically disabled, if anyone knows could you post,

thanks forum,

 :-D
Title: Re: How do you make the parent menu unclickable?
Post by: kweitzel on January 16, 2010, 06:06:59 PM
Placeholder Menu items are not a feature within the WB Menu Functions. Short of hardcoding the menu items into the template there is only two things you could try:

1) Use a menu call for every branch in your menu tree
2) Accept the fact that there is no placeholder and work around it by using a menu link item which links to the first subitem in the branch.

cheers

Klaus
Title: Re: How do you make the parent menu unclickable?
Post by: tsb on January 16, 2010, 07:44:57 PM
I kind of found a method in website baker 2.8, yet maybe not ideal.

I basically made a parent page, type as a menu link, then put in the menu link,

link:  external link > then I put in the websites home page.

This allows you to still have a drop down menu with the links but having the parent as a link to main-site and not opening up a new page, which I wanted to happen.

kinda, thanks,

 :-)
Title: Re: How do you make the parent menu unclickable?
Post by: Stefek on January 16, 2010, 08:28:03 PM
Placeholder Menu items are not a feature within the WB Menu Functions.
That's wrong.
The show_menu2() function and its CONDITIONAL FORMATTING options is a good and working option.

Stefek

Title: Re: How do you make the parent menu unclickable?
Post by: tsb on January 16, 2010, 09:22:46 PM
Do you know how the showmenu can make it so that the parent isnt a link?
I still want the childroot, drop down menu attached to them to work though

This is the code I have on the website,

        <div id="nav" class="clearfix">
            <?php show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, false, "\n</li>", false, false, false, '<ul id="header_menu" class="menu">'); ?><br />
        </div><!-- end nav -->

thanks,
Title: Re: How do you make the parent menu unclickable?
Post by: Stefek on January 16, 2010, 10:47:40 PM
$aItemOpen parameter:

'[ li][if(level==0){<span>[menu_title]</span>}else{<a href="[url]"><span>[menu_title]</span></a>}]'

all together your show_menu2 parameter call should look like this:

[/list]
Code: [Select]
<?php 
                show_menu2
(0SM2_ROOTSM2_ALLSM2_ALL
                &
#39;[li][if(LEVEL==0){<span>[menu_title]</span>}else{<a href="[url]"><span>[menu_title]</span></a>}]&#39;, //$aItemOpen 
                
"\n</li>"
                
false
                
false
                
false
                &
#39;<ul id="header_menu" class="menu">&#39;); 
                
?>


Also look at this example on the linked page (above link):

Code: [Select]
<?php
show_menu2
(
        
$aMenu          0,
        
$aStart         SM2_ROOT,
        
$aMaxLevel      SM2_CURR+1,
        
$aOptions       SM2_TRIM,
/* the next two lines have to do with the LINKS */
        
$aItemOpen      = &#39;[li][a][menu_title]</a>&#39;,
        
$aItemClose     = &#39;</li>&#39;,
/* the next two lines have to do with the Menu and Submenu Structure*/
        
$aMenuOpen      = &#39;[ul]&#39;,
        
$aMenuClose     = &#39;</ul>&#39;,

        
$aTopItemOpen   false,

        
$aTopMenuOpen   false
        
);
?>



Title: Re: How do you make the parent menu unclickable?
Post by: Argos on January 17, 2010, 12:31:15 AM
I basically made a parent page, type as a menu link, then put in the menu link,

link:  external link > then I put in the websites home page.

This allows you to still have a drop down menu with the links but having the parent as a link to main-site and not opening up a new page, which I wanted to happen.

That's unlogical and not user friendly. Clicking on a parent menu item brings you back to the homepage? That will feel like a bug to users. You should link to the first child page, or use stefeks info above.
Title: Re: How do you make the parent menu unclickable?
Post by: tsb on January 17, 2010, 09:30:18 PM
I had a go with the showmenus item open, yet Im using the css2 dropdown menu, and it doesnt seem to bring that element in when I put it into the templates index.php

Im not a very logical person  :-) more used to the creative side of things, so struggling to find the method with css and the functions in showmenu. I might link to the first child page that you mentioned.

Thanks for all the feedback and possibilities,

cheers,
Title: Re: How do you make the parent menu unclickable?
Post by: Stefek on January 17, 2010, 11:18:16 PM
it doesnt seem to bring that element in when I put it into the templates index.php
:-)

Oh yes, the CSS is another side if the menu.
But did you try the code? And was your Items unclickable then?

Regards,
Stefek
Title: Re: How do you make the parent menu unclickable?
Post by: tsb on January 18, 2010, 09:01:16 PM
sorry Stefan, I couldn't get it to work in my index.php file.

The menu in allcss2 template just breaks the dropdown menu, when I tried out both of the codes.

Im just not up on the coding side. cheers,
Title: Re: How do you make the parent menu unclickable?
Post by: Argos on January 18, 2010, 09:29:08 PM
It would help if we could see the site. Can we get a URL?
Title: Re: How do you make the parent menu unclickable?
Post by: tsb on January 18, 2010, 11:45:13 PM
Im building the website in website baker portable, so havent got it online yet. I could send you the template Ive put together, which is based on the allcss2 template.

I will upload the zip file and post it up here, this is the unfinished template currently,

heres the link,*removed*

I hope this helps, cheers from everyone that has replied to this currently, its great to get some feedback on this,
Title: Re: How do you make the parent menu unclickable?
Post by: Stefek on January 19, 2010, 03:16:44 AM
Hello,
this should work:

Code: [Select]
<?php     show_menu2(0,SM2_ROOT
                    
SM2_ALL
                    
SM2_ALL
                    &
#39;[li][if( level == 0 ){<a>[menu_title]</a>}else{<a href="[url]">[menu_title]</a>}]&#39;, 
                    
"\n</li>"
                    
false
                    
false
                    
false
                    &
#39;<ul id="header_menu" class="menu">&#39;
                
);         
            
?>


Regards,
Stefek
Title: Re: How do you make the parent menu unclickable?
Post by: tsb on January 19, 2010, 06:34:57 PM
Thank You so much Stefek!, the last code you posted, did exactly what I was wanting.

 :-)
Title: Re: How do you make the parent menu unclickable?
Post by: Stefek on January 19, 2010, 06:56:42 PM
You're welcome.

Regards,
Stefek
Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: tsb on May 24, 2010, 07:48:16 PM
Is there away of making the "home" link remain clickable?
Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: tsb on May 24, 2010, 11:32:16 PM
I dont really have knowledge of php, does it use if and else?

                    '
Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: Stefek on May 25, 2010, 12:47:10 AM
Hello,

php (as many other scriptng languages) uses if/else, of course.
But there is no "then" in PHP.

But you may use another /if/ in your menu call using the PageID.
See the Documentation of SM2 for details (you'll find inside the sm2 package/ZIP).

It would look like:
Code: [Select]
<?php




[li][if(level == 0){<a>[menu_title]</a>} if(page_id == 777){<a>XXXX[menu_title]XXXX</a>}else{<a href="[url]">[menu_title]</a>}]

replace 777 with your pageID.
replace XXXX with what ever fits your ideas.
Should work (no time to test).

Regards,
Stefek
Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: tsb on May 25, 2010, 05:24:37 PM
hey stefek, whats the xxxx for?do i put a web address in our is it the page name?

gonna try it out on the portable, cheers,
Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: Stefek on May 25, 2010, 05:38:44 PM
Hello,
I just marked the place where you should put you attention on.

Regards,
Stefek
Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: tsb on May 25, 2010, 08:49:13 PM
Stefek, just getting errors, if I can get this to work, I definitely will put some money towards your way.
I think if I can get the home page to work still then that would be brilliant.

 I could maybe go round the long way and make a link in html, hidding the home page on the menu.
just dont understand how to put the code in to get it to work, sorry.
Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: Argos on May 25, 2010, 09:45:49 PM
An alternative is to leave the homepage out of the menu by making it hidden (Page Settings > Visibility > Hidden). Then add a manual home link to the menu, like so:

Code: [Select]
<ul><li><a href="http://YOURDOMAIN.COM">Home</a></li></ul>
<?php show_menu2(0,SM2_ROOT
SM2_ALLSM2_ALL
&
#39;[li][if( level == 0 ){<a>[menu_title]</a>}else{<a href="[url]">[menu_title]</a>}]&#39;, 
"\n</li>"
falsefalsefalse
&
#39;<ul id="header_menu" class="menu">&#39;
);         
?>

You may have to style the URL of the Home button to match the rest of the menu.
Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: Stefek on May 25, 2010, 10:39:33 PM
Stefek, just getting errors, if I can get this to work, I definitely will put some money towards your way.

Hello,
if you really want to spent some bucks, then I always love to get PHP Books in exchange for my time ;-)
Amazon makes it possible.

But first, let's try to get the menu to work.

The following code should work properly:
Code: [Select]
<?php    
    show_menu2
(
        
0,SM2_ROOTSM2_ALLSM2_ALL
        &
#39;[li]
        
[if(level != || id == 777){ 
        <
a href="[url]">[menu_title]</a>
        }                     

        else{
        <
a>[menu_title]</a>
        }]&
#39;, 
        
&#39;</li>&#39;, 
        
false
        
false
        
false
        &
#39;<ul id="header_menu" class="menu">&#39;
    
);         
?>

Please try it, and let me know how it works.

You will need to replace 777 by the pageID of 'home'.

Kind regards,
Stefek

Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: tsb on May 25, 2010, 11:27:54 PM
that works a treat,
just give me a php book title :) and your address via message.
get it posted by the end of the week hopefully (I hope it aint too pricey mind),
very much appreciate everyones help in the coding part 8-)

thanks again
Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: Stefek on May 26, 2010, 12:33:16 AM
that works a treat,
just give me a php book title :) and your address via message.
get it posted by the end of the week hopefully (I hope it aint too pricey mind),

Hello TSB,
thanks for being willing to give something for something.
Give & Take is a essential foundation of any community.

I found something not too pricey.
You got PM.

Kind regards,
Stefek


Title: Re: How do you make the parent menu unclickable? <SOLVED>
Post by: Roych on December 03, 2013, 06:41:01 PM
Stefek, just getting errors, if I can get this to work, I definitely will put some money towards your way.

Hello,
if you really want to spent some bucks, then I always love to get PHP Books in exchange for my time ;-)
Amazon makes it possible.

But first, let's try to get the menu to work.

The following code should work properly:
Code: [Select]
<?php    
    show_menu2
(
        
0,SM2_ROOTSM2_ALLSM2_ALL
        
'[li]
        [if(level != 0 || id == 777){ 
        <a href="[url]">[menu_title]</a>
        }                     
        else{
        <a>[menu_title]</a>
        }]'

        
'</li>'
        
false
        
false
        
false
        
'<ul id="header_menu" class="menu">'
    
);         
?>

Please try it, and let me know how it works.

You will need to replace 777 by the pageID of 'home'.

Kind regards,
Stefek



Hi

I would like to achieve this also and was wondering if it is possible to add more id's to level !=0 than just home page. Or at least all id's clickable, but one!

Thank you

R.