Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

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.

Template Questions /

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

Custom vars in both PHP and SS templates


Go to End


9 Posts   5729 Views

Avatar
martimiz

Forum Moderator, 1391 Posts

26 March 2011 at 1:05am

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

Go to Top