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

Expression for .ss file


Go to End


5 Posts   2314 Views

Avatar
tareq1

Community Member, 2 Posts

26 September 2008 at 9:01pm

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

Forum Moderator, 5523 Posts

26 September 2008 at 9:42pm

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

Community Member, 8 Posts

29 September 2008 at 7:21pm

Edited: 30/09/2008 6:41pm

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

Forum Moderator, 5523 Posts

30 September 2008 at 9:11pm

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

Community Member, 8 Posts

22 October 2008 at 8:19pm

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

thanx once again :)
ciao.