/** * Wrap layout around returned content from primary dispatch * * @return mixed $content Raw content string, Alloy\Module\Response object, or generic object that implements __toString */ public function wrapLayout($content) { $kernel = \Kernel(); $request = $kernel->request(); $response = $kernel->response(); $response->contentType('text/html'); $layoutName = null; if ($content instanceof Alloy\View\Template) { $layoutName = $content->layout(); } // Use config template if none other specified and request is not Ajax or CLI if (null === $layoutName && !$request->isAjax() && !$request->isCli()) { $layoutName = $kernel->config('app.layout.template', 'app'); } if ($layoutName && true === $kernel->config('app.layout.enabled', false)) { $layout = new \Alloy\View\Template($layoutName, $request->format); $layout->path($kernel->config('app.path.layouts'))->format($request->format); // Ensure layout exists if (false === $layout->exists()) { return $content; } // Pass along set response status and data if we can if ($content instanceof Alloy\Module\Response) { $layout->status($content->status()); $layout->errors($content->errors()); } // Pass set title up to layout to override at template level if ($content instanceof Alloy\View\Template) { // Force render layout so we can pull out variables set in template $contentRendered = $content->content(); $layout->head()->title($content->head()->title()); $content = $contentRendered; } $layout->set(array('kernel' => $kernel, 'content' => $content)); return $layout; } return $content; }
/** * Return template content */ public function content($parsePHP = true) { // Set static level tracker //self::$_level = 0; // Set template vars $content = parent::content($parsePHP); // Reset static level tracker self::$_level = 0; return $content; }
/** * Return template content */ public function content($parsePHP = true) { // Set template vars $this->set('fields', $this->fields()); return parent::content($parsePHP); }
/** * Return template content */ public function content($parsePHP = true) { // Set template vars return parent::content($parsePHP); }
/** * Return template content */ public function content($parsePHP = true) { // Set template vars $this->set('data', $this->_data); $this->set('columns', $this->columns()); return parent::content($parsePHP); }