hi
How can I check in the template *.ss one of the variables if it is empty?
I try
<% if Linkwww %>
<div class="Linkwww"><a href="http://{$Linkwww}">$Linkwww</a></div>
<% end_if %>
but nothing goes
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
hi
How can I check in the template *.ss one of the variables if it is empty?
I try
<% if Linkwww %>
<div class="Linkwww"><a href="http://{$Linkwww}">$Linkwww</a></div>
<% end_if %>
but nothing goes
How are you defining your variable?
Test it out with:
<% if Content %>
This page has content!
<% end_if %>
That should work.
--
If blocks (http://doc.silverstripe.com/doku.php?id=templates)
<% if Property %>
<% end_if %>
If blocks let you mark off optional content in your template. The optional content will only be shown if the requested field / method returns a nonzero value.
thanks
But as it turned out the problem in another
l have next code on my ProdHolder.ss
<% control Children %>
<div class="ProdBl">
<div class="prev"><a href="$Link" title="$Title.XML">$Photo.SetWidth(150)</a></div>
<div class="Prodtext">
<h4><a href="$Link" title="$Title.XML">$Title</a></h4>
$Content
$Linkwww
<% if Linkwww %>
<div class="Linkwww"><a href="http://{$Linkwww}">$Linkwww</a></div>
<% end_if %>
</div>
<div class="clear1"><!-- --></div>
</div>
<% end_control %>