public function render() { $rendered = parent::render(); // See if we need to render this template with a layout if ($this->layout !== FALSE) { $params = $this->data; // If no layout was specificed, but we need a layout, // try and use the default, if it exists if ($this->layout === NULL && file_exists(TEMPLATES_PATH . '+layout.php')) { $this->layout = '/layout'; } // If we have a layout to render, wrap that around our content if ($this->layout) { $params = array_merge($params, LayoutController::$data); $params = array_merge($params, array('content' => (string) $rendered)); $rendered = Template::layout($this->layout, $params); $rendered->layout = FALSE; } } return (string) $rendered; }
/** * Specify the layout into which the views will be rendered. * * Allows overriding the default layout. This is especially useful to set a * default layout for a controller which overrides the default layout of the * application. * * @param string $layout The name of the layout. * * @return void */ public static function setLayout($layout) { self::$layout = $layout; }
public static function init() { // If the application config file hasn't been loaded, do it now if (!self::$ci->config->item('template.theme_paths')) { self::$ci->config->load('application'); } // Store our settings self::$site_path = self::$ci->config->item('template.site_path'); self::$theme_paths = self::$ci->config->item('template.theme_paths'); self::$layout = self::$ci->config->item('template.default_layout'); self::$default_theme = self::$ci->config->item('template.default_theme'); self::$parse_views = self::$ci->config->item('template.parse_views'); // Store our orig view path, so we can reset it self::$orig_view_path = self::$ci->load->_ci_view_path; log_message('debug', 'Template library loaded'); }
public function set($layout) { self::$layout = $layout; }