layoutId = $layoutId; $this->basePath = is_null($basePath) ? JPATH_ROOT . '/layouts' : rtrim($basePath, DIRECTORY_SEPARATOR); } /** * Method to render the layout. * * @param object $displayData Object which properties are used inside the layout file to build displayed output * * @return string The necessary HTML to display the layout * * @since 3.0 */ public function render($displayData) { $layoutOutput = ''; // Check possible overrides, and build the full path to layout file $path = $this->getPath(); // If there exists such a layout file, include it and collect its output if (!empty($path)) { ob_start(); include $path; $layoutOutput = ob_get_contents(); ob_end_clean(); } return $layoutOutput; } /** * Method to finds the full real file path, checking possible overrides * * @return string The full path to the layout file * * @since 3.0 */ protected function getPath() { jimport('joomla.filesystem.path'); if (is_null($this->fullPath) && !empty($this->layoutId)) { $rawPath = str_replace('.', '/', $this->layoutId) . '.php'; $fileName = basename($rawPath); $filePath = dirname($rawPath); $possiblePaths = array( JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/layouts/' . $filePath, $this->basePath . '/' . $filePath ); $this->fullPath = JPath::find($possiblePaths, $fileName); } return $this->fullPath; } }