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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

If blocks


Go to End


2 Posts   2153 Views

Avatar
KatB

Community Member, 105 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