Jump to:

3434 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » if-condition throws syntax error

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

Page: 1
Go to End
Author Topic: 1852 Views
  • brokemeister
    Avatar
    Community Member
    30 Posts

    if-condition throws syntax error Link to this post

    Hi!

    I always get following error and cannot figure out what is wrong:

    Parse error: syntax error, unexpected '}' in ....\...MagazinViewSingle.ss on line 41

    Template
             <div class="item $Item.ClassName">
             <% if Item.ClassName == ArticleDataObject %>
                <H2>$Item.Title</H2>
                <p>$Item.Text</p>
             <% else %>
                Content Type is not configured in MagazinViewSingle.ss
             <% end_if %>
             </div>

    Any ideas or hints?

    Thanks

    Greetz from Germany,

    Malte

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: if-condition throws syntax error Link to this post

    <% if Item.ClassName == ArticleDataObject %>

    should be :

    <% if Item.ClassName = ArticleDataObject %>

  • brokemeister
    Avatar
    Community Member
    30 Posts

    Re: if-condition throws syntax error Link to this post

    Hi lemon8,

    The same error still occures..

    The output of Item.ClassName works pretty well.
    By the way "Item" is a record...

    Cheers,

    Malte

  • banal
    Avatar
    Community Member
    901 Posts

    Re: if-condition throws syntax error Link to this post

    I suggest you do the following:

    <% control Item %>
    <div class="item $ClassName">
       <% if ClassName = ArticleDataObject %>
          <h2>$Title</h2>
          <p>$Text</p>
       <% else %>
          Content Type is not configured in MagazinViewSingle.ss
       <% end_if %>
    </div>
    <% end_control %>

  • brokemeister
    Avatar
    Community Member
    30 Posts

    Re: if-condition throws syntax error Link to this post

    Hi banal,

    thanks for your reply.

    It's working...

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