Silverstripe 4
I have extended PageController via an extension. The controller should now use another template-file for rendering.
renderWith may do the trick. But I don’t know how to use it in the right way
Thanks in advance.
Fabian
Silverstripe 4
I have extended PageController via an extension. The controller should now use another template-file for rendering.
renderWith may do the trick. But I don’t know how to use it in the right way
Thanks in advance.
Fabian
This should start you off:
$data= [
'YourVariable' => 'Hello world',
];
return $this->owner->customise($data)->renderWith('YourPageTemplate');
Hej thank you jellygnite,
but where do I have to put that statement?
Instead of using templates/Layout/Page.ss
I want to use a diffrent one i.e. MyExtension/templates/Layout/PageCustom.ss
IS this not possible?
Hi,
I found out that index is the function where the renderWith magic should be placed. Now another question appears. I just want to deliver the sub-template which is added by the $Layout-variable. Now when using renderwith it only takes the first parameter given as the main-template. It uses the same template to render $Layout aswell. So I m getting the complete Page rendered to Layout, too!!
How can I tell renderWith, to use the given template as subtemplate for Page.ss?
class OrderProfileFeature_ProductController extends DataExtension{
public function index(HTTPRequest $request){
return $this->getOwner()->renderWith([ThemeResourceLoader::inst()->findTemplate(
"Schrattenholz\\OrderProfileFeature\\Layout\\Product",
SSViewer::config()->uninherited('themes')
),"Page"]);
}
}