FuelPHP Bin
Sign in
Url:
Fork
<?php class Controller_Base_Template extends \Controller_Hybrid { public $template = 'template'; public $dataGlobal = array(); public $themeOverride = null; public function before() { // Set template $this->theme = \Theme::instance(); // If ajax or content_only, set a theme with an empty layout if (\Input::is_ajax() || \Input::get('content_only')) { $this->theme->active('default'); $this->theme->set_template('_layout/empty'); $this->template = ''; return parent::before(); } else { $this->themeOverride !== null and $this->theme->active($this->themeOverride); $this->theme->set_template($this->template); } // Don't re-set Media if is an HMVC request !\Request::is_hmvc() and $this->setMedia(); } public function action_index() { } public function action_404() { $messages = array('Uh Oh!', 'Huh ?'); $data['notfound_title'] = $messages[array_rand($messages)]; $this->dataGlobal['pageTitle'] = 'Page introuvable!'; $this->theme->set_partial('content', '_partials/404')->set($data); } public function after($response) { !\Request::is_hmvc() and $this->theme->get_template()->set_global($this->dataGlobal); // If nothing was returned set the theme instance as the response if (empty($response)) { $response = \Response::forge($this->theme); } if (!$response instanceof \Response) { $response = \Response::forge($response); } return parent::after($response); } public function setMedia() { } }