Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » check variables

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: 806 Views
  • fiord
    Avatar
    Community Member
    79 Posts

    check variables Link to this post

    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

  • Piklets
    Avatar
    Community Member
    36 Posts

    Re: check variables Link to this post

    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.

  • fiord
    Avatar
    Community Member
    79 Posts

    Re: check variables Link to this post

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


    my ProdHolder.ss does not see $Linkwww from Children Pages

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