Source for file file.php
Documentation is available at file.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Base class for rendering a display layout
* loaded from from a layout file
* @package Joomla.Libraries
* @see http://docs.joomla.org/Sharing_layouts_across_views_or_extensions_with_JLayout
* @var string Dot separated path to the layout file, relative to base path
* @var string Base path to use when loading layout files
* @var string Full path to actual layout files, after possible template override check
* Paths to search for layouts
* Method to instantiate the file-based layout.
* @param string $layoutId Dot separated path to the layout file, relative to base path
* @param string $basePath Base path to use when loading layout files
* @param mixed $options Optional custom options to load. JRegistry or array format [@since 3.2]
public function __construct($layoutId, $basePath =
null, $options =
null)
// Initialise / Load options
* 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
public function render($displayData)
// Check possible overrides, and build the full path to layout file
if ($this->options->get('debug', false))
// If there exists such a layout file, include it and collect its output
* Method to finds the full real file path, checking possible overrides
* @return string The full path to the layout file
$suffixes =
$this->options->get('suffixes', array());
// Search for suffixed versions. Example: tags.j31.php
foreach ($suffixes as $suffix)
$this->addDebugMessage('<strong>Searching layout for:</strong> ' .
$rawPath);
$this->addDebugMessage('<strong>Searching layout for:</strong> ' .
$rawPath);
* Add one path to include in layout search. Proxy of addIncludePaths()
* @param string $path The path to search for layouts
* Add one or more paths to include in layout search
* @param string $paths The path or array of paths to search for layouts
* Remove one path from the layout search
* @param string $path The path to remove from the layout search
* Remove one or more paths to exclude in layout search
* @param string $paths The path or array of paths to remove for the layout search
* Validate that the active component is valid
* @param string $option URL Option of the component. Example: com_content
// By default we will validate the active component
$component =
($option !==
null) ?
$option :
$this->options->get('component', null);
// Latest check: component exists and is enabled
* Method to change the component where search for layouts
* @param string $option URL Option of the component. Example: com_content
* @return mixed Component option string | null for none
switch ((string)
$option)
$parts =
explode('/', JPATH_COMPONENT);
$component =
end($parts);
$this->options->set('component', $component);
* Function to initialise the application client
* @param mixed $client Frontend: 'site' or 0 | Backend: 'admin' or 1
// Force string conversion to avoid unexpected states
switch ((string)
$client)
$this->options->set('client', $client);
* @param string $layoutId Layout to render
* Refresh the list of include paths
// (1 - lower priority) Frontend base layouts
// (2) Standard Joomla! layouts overriden
// Component layouts & overrides if exist
$component =
$this->options->get('component', null);
if ($this->options->get('client') ==
0)
// (4) Component template overrides path
// (5 - highest priority) Received a custom high priority path ?
* @param boolean $debug Enable / Disable debug
$this->options->set('debug', (boolean)
$debug);
* Render a layout with the same include paths & options
* @param object $layoutId Object which properties are used inside the layout file to build displayed output
* @param mixed $displayData Data to be rendered
* @return string The necessary HTML to display the layout
public function sublayout($layoutId, $displayData)
// Sublayouts are searched in a subfolder with the name of the current layout
$layoutId =
$this->layoutId .
'.' .
$layoutId;
$sublayout =
new static($layoutId, $this->basePath, $this->options);
return $sublayout->render($displayData);
Documentation generated on Tue, 19 Nov 2013 15:03:07 +0100 by phpDocumentor 1.4.3