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

Expression for .ss file


Reply

5 Posts   1538 Views

Avatar
tareq1

26 September 2008 at 9:01pm Community Member, 2 Posts

Hi All ,

I need to write relational expression in .ss file.

I m trying this way but its giving me error.

<% $MenuTitle == 'xyz' %>
Hello
<% end_if %>

If anybody did this before please guide me.

Will be waiting for your reply .

Tareq :)

Avatar
Willr

26 September 2008 at 9:42pm Forum Moderator, 5511 Posts

The template parser is pretty basic - you can see what you can do here -> http://doc.silverstripe.com/doku.php?id=built-in-page-controls .. It should be able to support = to at least.

Try

<% if MenuTitle = xyz %>
Hello
<% end_if %>

Avatar
Tareq

29 September 2008 at 7:21pm (Last edited: 30 September 2008 6:41pm), Community Member, 8 Posts

Hi Willr,

Thanx a lot .

ohh,I checked this link now, while using logical operator "||" in expression it doesn't work.

<% control Menu(1) %>
<% if MenuTitle = Contactus || MenuTitle = Privacy %>
   <% else %>
      <li><a href="$Link" class="$LinkingMode">$MenuTitle</a></li>
   <% end_if %>
<% end_control %>

Its not allowing me to write above expression with "OR" operator.

Parse error: syntax error, unexpected '}' in D:\project\silver\silverstripe-cache\.cacheD..project.silver.themes.project_xyz.templates.Page.ss on line 94

Please guide me that where i m doing wrong or is their any updation in CMS.

ciao.

Regards,
Tareq :)

Avatar
Willr

30 September 2008 at 9:11pm Forum Moderator, 5511 Posts

as I said the template parser is pretty basic :P you might have to do

<% control Menu(1) %>
<% if MenuTitle = Contactus %>
<% else %>
<% if MenuTitle = Privacy %>
<% else %>
<li><a href="$Link" class="$LinkingMode">$MenuTitle</a></li>
<% end_if %>
<% end_control %>

Which I think does the same just have to nestle the ifs

Avatar
Tareq

22 October 2008 at 8:19pm Community Member, 8 Posts

Hiaa willr,
sorry i m sending thanx late.
it allready done with the same link which u sent me b4.

thanx once again :)
ciao.