Last week I tried to access a function from different PageTypes inside one FolderPage (see http://silverstripe.org/general-questions/show/14811). 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:
My class hierarchy:
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 %> $MyFirstImage <h2><a href="$Link">$Title</a></h2> $ShortText </div> <% 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 DefaultPage.ss output). Putting MyFirstImage to DefaultPage would be almost an exact copy of the function already present in the controller (I hate that).
From FolderPage.ss 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 FolderPage.ss? I hope this is somehow understandable.