Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » If blocks

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1660 Views
  • KatB
    Avatar
    Community Member
    94 Posts

    If blocks Link to this post

    'If blocks' documentation referred to: http://doc.silverstripe.com/doku.php?id=templates#if_blocks

    It says in the documentation that currently negations such as x != 3 are not available. Does this mean that tests such as x == 3 are available?

    Is it testing only on the presence of the particular property?
    Can you test subproperty elements: eg. <% if $LinkingMode.current %> (stuff goes here) <% end_if %> ?

    Things are looking up!

  • elijahlofgren
    Avatar
    Google Summer of Code Hacker
    222 Posts

    Re: If blocks Link to this post

    > Does this mean that tests such as x == 3 are available?
    Yes, but for some reason, the comparison use a single = sign. Example here:
    http://www.silverstripe.com/silverstripe-development/flat/1663?showPost=1673#post1673

    > Can you test subproperty elements: eg. <% if $LinkingMode.current %> (stuff goes here) <% end_if %> ?

    You should be able test anything that can be accessed. I think syntax you want is <% if LinkingMode = current %>

    Example:

       <% control Menu(1) %>   
       <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.</span></a>
       <% if LinkingMode = current %>
       This is the current page
       <% end_if %>
       </li>
       <% end_control %>

    For similar examples see:
    http://doc.silverstripe.com/doku.php?id=built-in-page-controls#page_controls_that_can_be_used_anywhere

    > Things are looking up!

    Great! I hope things continue to go well for you.

    Have a good weekend,

    Elijah

    1660 Views
Page: 1
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.