$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);
}
/**
- * @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)
{
}