diff --git a/docs/en/02_Developer_Guides/01_Templates/04_Rendering_Templates.md b/docs/en/02_Developer_Guides/01_Templates/04_Rendering_Templates.md index 919536295..46e296d9d 100644 --- a/docs/en/02_Developer_Guides/01_Templates/04_Rendering_Templates.md +++ b/docs/en/02_Developer_Guides/01_Templates/04_Rendering_Templates.md @@ -34,6 +34,19 @@ echo $arrayData->renderWith('Coach_Message'); // returns "John is the Head Coach on our team." +``` +If your template is a Layout template that needs to be rendered into the main Page template (to include a header and footer, for example), you need to render your Layout template into a string, and pass that as the Layout parameter to the Page template. + +```php +$data = [ + 'Title' => 'Message from the Head Coach' +]; + +return $this->customise([ + 'Layout' => $this + ->customise($data) + ->renderWith(['Template\Path\From\templates\Layout\Coach_Message']) +])->renderWith(['Page']); ``` [info] @@ -107,4 +120,4 @@ class PageController extends ContentController * [Controller actions/DataObjects as pages](https://www.silverstripe.org/learn/lessons/v4/controller-actions-dataobjects-as-pages-1) * [AJAX behaviour and ViewableData](https://www.silverstripe.org/learn/lessons/v4/ajax-behaviour-and-viewabledata-1) * [Dealing with arbitrary template data](https://www.silverstripe.org/learn/lessons/v4/dealing-with-arbitrary-template-data-1) -* [Creating filtered views](https://www.silverstripe.org/learn/lessons/v4/creating-filtered-views-1) \ No newline at end of file +* [Creating filtered views](https://www.silverstripe.org/learn/lessons/v4/creating-filtered-views-1)