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.

Template Questions /

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

if-condition throws syntax error


Go to End


5 Posts   2862 Views

Avatar
brokemeister

Community Member, 30 Posts

2 July 2009 at 8:32pm

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

Avatar
Fuzz10

Community Member, 791 Posts

2 July 2009 at 9:54pm

<% if Item.ClassName == ArticleDataObject %>

should be :

<% if Item.ClassName = ArticleDataObject %>

Avatar
brokemeister

Community Member, 30 Posts

2 July 2009 at 10:01pm

Hi lemon8,

The same error still occures.. :(

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

Cheers,

Malte

Avatar
bummzack

Community Member, 904 Posts

2 July 2009 at 10:58pm

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

Avatar
brokemeister

Community Member, 30 Posts

2 July 2009 at 11:24pm

Hi banal,

thanks for your reply.

It's working...