21297 Posts in 5734 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 425 Views |
-
Best way to hide some menu item

12 January 2012 at 3:52am
Hello
I have this scenario where a website has 2 main section (A and B) those are not part of the menu they are hardcoded (maybe they should be)
Their main menu is common exept for 2 or 3 items that changes or dissapear . So my question is is there a best way to dynamicaly hide some menu item depending on a global variable or something else
If someone could give me a link to some doc or tutorial I could use for that it would be greatly apréciated
Thanks
-
Re: Best way to hide some menu item

14 January 2012 at 4:30pm
You can hide given pages in the CMS by unticking the 'Show In Menus' checkbox under the behaviour tab.
-
Re: Best way to hide some menu item

15 March 2012 at 12:41am
Hello Willr.
I just saw your answer.
I can not do it like that, because the visiblity of my menu item depends on wich section A or B I'm. Those sections are not a menu level in my scenario they are defining a global variable to select the visible and not visible menu item.
Thanks
-
Re: Best way to hide some menu item

15 March 2012 at 3:13am Last edited: 15 March 2012 3:16am
You could define something like this on your Page class
public static $db = array(
"HideFromMenuA" => "Boolean",
"HideFromMenuB" => "Boolean"
);Then for your main menus something like this for Menu A
<ul>
<% control Menu(1) %>
<% if HideFromMenuA == 0 %>
<li class="$LinkingMode"><a href="$Link" title="Go to the "{$Title.HTMLATT}" page">$MenuTitle</a></li>
<% end_if %>
<% end_control %>
</ul>And this for Menu B
<ul>
<% control Menu(1) %>
<% if HideFromMenuB == 0 %>
<li class="$LinkingMode"><a href="$Link" title="Go to the "{$Title.HTMLATT}" page">$MenuTitle</a></li>
<% end_if %>
<% end_control %>
</ul> -
Re: Best way to hide some menu item

15 March 2012 at 4:45am
Thanks a lot
It looks great and simple.
The only problem I have now is how to trigger those bollean values with my 2 hardcoded buttons
Thanks
-
Re: Best way to hide some menu item

15 March 2012 at 5:21am
What do you mean by hardcoded buttons? Can you post your code?
-
Re: Best way to hide some menu item

15 March 2012 at 5:26am
Hello
These are two hardcoded button <a href> buttons in the Page.ss template
But I guess it is not the good solution as they could never relate to the bollean variables.I will first try to set up your code and see how it goes from there
Thanks for your help
T
| 425 Views | ||
|
Page:
1
|
Go to Top |



