Jump to:

3447 Posts in 1032 Topics by 872 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: 3206 Views
  • martimiz
    Forum Moderator
    1091 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 %>

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.