Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Expression for .ss file

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: 1531 Views
  • tareq1
    Avatar
    Community Member
    2 Posts

    Expression for .ss file Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Expression for .ss file Link to this post

    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 %>

  • Tareq
    Avatar
    Community Member
    8 Posts

    Re: Expression for .ss file Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Expression for .ss file Link to this post

    as I said the template parser is pretty basic 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

  • Tareq
    Avatar
    Community Member
    8 Posts

    Re: Expression for .ss file Link to this post

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

    thanx once again
    ciao.

    1531 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.