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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Template Questions /

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

Controlling different pagetypes possible?

Go to End



Community Member, 88 Posts

16 November 2010 at 5:20am

Last week I tried to access a function from different PageTypes inside one FolderPage (see In the end I found a workaround, but went into this problem again today. Although I was sure, this should be no problem in Silverstripe, it turns out to be somehow impossible (I believe).

My page hierarchy is as follows:
|-> DefaultPage
|-> Page
My class hierarchy:
|-> DefaultPage
|-> FolderPage

In FolderPage I'd like to control all teaserable child pages of a FolderPage:

		<% if Children %>
		<% control Children %>
		<% if Teaserable %>
		<% if Last %>
		<div class="article last">
		<% else %>
		<div class="article">
		<% end_if %>
			<h2><a href="$Link">$Title</a></h2>
		<% end_if %>
		<% end_control %>
		<% end_if %>

Although $MyFirstImage exists in DefaultPage_Controller, it's not callable from Template and I can't think of any workaround for this.
Making MyFirstImage static is no solution due to required object scope (for output). Putting MyFirstImage to DefaultPage would be almost an exact copy of the function already present in the controller (I hate that).

From I can only call functions on DefaultPage not from DefaultPage_Controller. Is there any other way I could somehow load the DefaultPage_Controller inside FolderPage_Controller or call functions of DefaultPage_Controller from I hope this is somehow understandable.