Using SilverStripe 3.1 I have laid out a FrontPage page type that loops through its children to produce a big tall scrolling page. It has all kinds of different page types in it and I access their templates by creating their controllers on the fly by adding on to the Page class:
class Page extends SiteTree {
.....
function RenderAsChild($templateName = null) {
if(!$templateName) $templateName = $this->ClassName;
if(!$this->pageController){
$class = $this->ClassName . "_Controller";
$this->pageController = new $class($this);
}
return $this->pageController->renderForHolderPage($templateName);
}
and in the controller:
class Page_Controller extends ContentController {
....
function renderForHolderPage($templateName = null) {
if(!$templateName) $templateName = $this->ClassName;
return $this->renderWith(array($templateName));
}
In this way I can render pages and manage their templates and special features easily while still treating them all the same way in the template, something like:
<% loop $Children %>
<% if $ClassName = 'FancyPage' %>
$RenderAsChild
......
The thing is I want to use the userforms extension this way but in the template in a loop or control it shows up just as a page. It does not appear to know anything about the form or the UserDefinedForm object.
Is there a way to get userforms to render as a child in a template?