]> _ Git - cubist_cms-back.git/commitdiff
Naming tweak + allow body_class to be overridden. WIP #2738 @0.25
authorStephen Cameron <stephen@cubedesigners.com>
Thu, 11 Jul 2019 17:59:21 +0000 (19:59 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Thu, 11 Jul 2019 17:59:21 +0000 (19:59 +0200)
src/app/Http/Controllers/CubistPageController.php
src/app/Template/TemplateAbstract.php

index 196a3f1439f88aa20014fce6efa0672b18f701aa..5ea27544d31b9c5acedd072d699efbe380a94e9d 100644 (file)
@@ -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);
     }
 
index 5d3096ee864c82024f480fa35bd6adfb7581f583..e8b1434addf2ef26df114d22b0fde5696828d545 100644 (file)
@@ -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)
     {
 
     }