Jump to:

22976 Posts in 11702 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Fun with menus

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 1290 Views
  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: Fun with menus Link to this post

    Yes, but this means if the user changes the Title... it breaks

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: Fun with menus Link to this post

    Refer to the id instead? Not so nice anymore...

  • Juanitou
    Avatar
    Community Member
    322 Posts

    Re: Fun with menus Link to this post

    Hi!

    Martimiz, I think you're wrong: 'if' structures accept the != operator. What they don't accept is apostrophes or spaces or non-ASCII characters, so:

    <% if MenuTitle != 'My Headline' %>

    Does not work, but:

    <% if URLSegment != my-headline %>

    should work.

    Hope it helps,
    Juan

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: Fun with menus Link to this post

    @Juanitou
    You're absolutely right - that was definitely mixed up - must have been the holydays. Sorry Pidgeon, I guess I'll go and hide for a while

  • Juanitou
    Avatar
    Community Member
    322 Posts

    Re: Fun with menus Link to this post

    Hey Martimiz, don't hide! Your contribution is useful.

    If I know well this issue is because I'm using SS for multi-lingual sites. The actual 'if' parser is useless with Titles, MenuTitles and the such as long as it does not recognize spaces and special characters. Happily, with SS, it's easy to find workarounds.

    Best regards,
    Juan

  • Junglefish
    Avatar
    Community Member
    104 Posts

    Re: Fun with menus Link to this post

    Guys!

    So many excellent suggestions, I can't thank you enough.

    @Pigeon. Thanks for being so thorough with your explanation, it's helped my understanding of the SS framework a lot.

    For anyone following this thread - I'm actually going to use the Martimez/Juanitou 'quick-n-dirty' solution (no offense intended). In my case I have a one-off requirement to move one item from the left-bar to the right-bar. So I think that hard-coding it is actually the 'safe' option in this case and it doesn't give the client any extra checkboxes to worry about. I've used <% if ID != 54 %> to identify the particular node, so the client can alter the page title if neccessary.

    If the client's requirement changes in the future, I know I have the 'elegent' solution to fall back on.

    Again, thanks all.

    jf\

    1290 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.