3212 Posts in 847 Topics by 809 members
| Go to End | Next > | |
| Author | Topic: | 6258 Views |
-
Problem with <%if > control

7 June 2010 at 9:55am
This control block
<% if $URLSegment='edit' %>
$StudentEdit
<% else_if $URLSegment='add' %>
$StudentAdd
<% end_if %>is throwing this error.
Parse error: syntax error, unexpected '}' in C:\WINDOWS\Temp\silverstripe-cacheE--websites-_SilverStripe-Reception-Screen.v2.4.0\.cacheE..websites._SilverStripe.Reception-Screen.v2.4.0.themes.J2.templates.Layout.StudentEdit.ss on line 222
Yet went I use the %StudentEdit and $StudentAdd in the same template without the if control all is fine.
Any ideas anyone?
-
Re: Problem with <%if > control

7 June 2010 at 10:14am Last edited: 7 June 2010 8:22pm
SS's templating language is very simple and doesn't allow for great amount of logic.
When doing comparisons, you don't need to use quote marks or apostrophes.
<% if URLSegment = edit %>
$StudentEdit
<% else_if URLSegment = add %>
$StudentAdd
<% end_if %>Personally, i would never compare URLSegments in the template as the site administrator will be able to change these, thus breaking the site.
-
Re: Problem with <%if > control

7 June 2010 at 7:31pm
I have the same problem with:
<% if $ClassName = HomePage %>
<% include Menu2 %>
<% end_if %> -
Re: Problem with <%if > control

7 June 2010 at 8:23pm
Sorry, also in the <% %> you must not use the $ before the variable name.
<% if ClassName = HomePage %>
<% include Menu2 %>
<% end_if %> -
Re: Problem with <%if > control

7 June 2010 at 8:38pm
thx, but what about that?
<% if ClassName != ArticleHolder && ClassName != StaffHolder %>
<% include Menu2 %>
<% end_if %> -
Re: Problem with <%if > control

7 June 2010 at 8:42pm
Please check docs: http://doc.silverstripe.org/templates#if_blocks
No quotes around values, no $ before properties, only four simple boolean operators.
Hope it helps,
Juan -
Re: Problem with <%if > control

8 June 2010 at 3:51am Last edited: 8 June 2010 4:02am
Of course i checked it before to didn't ask u stupid questions and it's logical that PHP property name always started with $ sign so it's not obvious and if u look at <% if Property != value &> here is strange sign & at the end of the row
and
if ( $Property && $Property)
it's the same as if ( $Property == TRUE && $Property == TRUE)don't be angry about my questions, just manual must be corrected and there won't such questions anymore
P.S. Sorry
| 6258 Views | ||
| Go to Top | Next > |


