From: Stephen Cameron Date: Thu, 11 Jul 2019 17:59:21 +0000 (+0200) Subject: Naming tweak + allow body_class to be overridden. WIP #2738 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=00324cb43269eb8f7d9923360eabb9808345cd22;p=cubist_cms-back.git Naming tweak + allow body_class to be overridden. WIP #2738 @0.25 --- diff --git a/src/app/Http/Controllers/CubistPageController.php b/src/app/Http/Controllers/CubistPageController.php index 196a3f1..5ea2754 100644 --- a/src/app/Http/Controllers/CubistPageController.php +++ b/src/app/Http/Controllers/CubistPageController.php @@ -22,9 +22,11 @@ class CubistPageController extends CubistFrontController $this->data['title'] = $page->title; $this->data['page'] = $page->getPageData(); - $page->getUsedTemplate()->injectDataInView($this->data); $this->data['body_class'] = 'page-' . Str::slug($page->name); + // Page templates can modify/inject data before it is passed to the view + $page->getUsedTemplate()->setData($this->data); + return view('pages.' . $page->template, $this->data); } diff --git a/src/app/Template/TemplateAbstract.php b/src/app/Template/TemplateAbstract.php index 5d3096e..e8b1434 100644 --- a/src/app/Template/TemplateAbstract.php +++ b/src/app/Template/TemplateAbstract.php @@ -136,9 +136,13 @@ class TemplateAbstract /** - * @param $data array + * @param $data array Current page data for the view + * This function is designed to be overridden by individual + * templates to allow extra data to be passed to the view. + * This is necessary because all CMS Pages share the same + * controller and action. */ - public function injectDataInView(&$data) + public function setData(&$data) { }