Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

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

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

If blocks


Reply


2 Posts   1726 Views

Avatar
KatB

Community Member, 94 Posts

29 June 2007 at 5:48pm

'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! :)

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

30 June 2007 at 4:36am

Edited: 30/06/2007 4:37am

> 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