Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Custom vars in both PHP and SS templates

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

Page: 1 2
Go to End
Author Topic: 3010 Views
  • martimiz
    Avatar
    Forum Moderator
    1037 Posts

    Re: Custom vars in both PHP and SS templates Link to this post

    An old post, but if anyone is still interested:

    I found allthough something like <% if Top.SomeSetting = SomeValue %> will generate a parsing error, simple checking on true or false <% if Top.SomeSetting %> seems to work allright, meaning you could check on some Top setting from within a control structure and retrieve a sub property (in 2.4.5):

    // in the Page_Controler
    function isTheRightPage() {
       return ($this->Title == 'SomeTitle')? true: false;
    }

    <% control MyObjects %>
       <% if Top.isTheRightPage %>
          <!-- do something with the object based on the page title %>
       <% end_if %>
    <% end_control %>

    3010 Views
Page: 1 2
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.