JModuleHelper/getLayoutPath: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Get the path to a layout for a module
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton... |
No edit summary |
||
| Line 9: | Line 9: | ||
===Syntax=== | ===Syntax=== | ||
<source lang="php"> | <source lang="php">getLayoutPath($module, $layout= 'default')</source> | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 36: | Line 36: | ||
===Source Body=== | ===Source Body=== | ||
<source lang="php"> | <source lang="php"> | ||
function getLayoutPath($module, $layout = 'default') | |||
{ | { | ||
$ | global $mainframe; | ||
// Build the template and base path for the layout | // Build the template and base path for the layout | ||
$tPath = JPATH_BASE.' | $tPath = JPATH_BASE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.$module.DS.$layout.'.php'; | ||
$bPath = JPATH_BASE.' | $bPath = JPATH_BASE.DS.'modules'.DS.$module.DS.'tmpl'.DS.$layout.'.php'; | ||
// If the template has a layout override use it | // If the template has a layout override use it | ||
if (file_exists($tPath)) { | if (file_exists($tPath)) { | ||
return $tPath; | return $tPath; | ||
} | } else { | ||
return $bPath; | return $bPath; | ||
} | } | ||
Revision as of 22:09, 22 March 2010
Description
Get the path to a layout for a module
Template:Description:JModuleHelper/getLayoutPath
Syntax
getLayoutPath($module, $layout= 'default')
| Parameter Name | Default Value | Description |
|---|---|---|
| $module | $module The name of the module | |
| $layout | 'default' | $layout The name of the module layout |
Returns
string The path to the module layout
Defined in
libraries/joomla/application/module/helper.php
Importing
jimport( 'joomla.application.module.helper' );
Source Body
function getLayoutPath($module, $layout = 'default')
{
global $mainframe;
// Build the template and base path for the layout
$tPath = JPATH_BASE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.$module.DS.$layout.'.php';
$bPath = JPATH_BASE.DS.'modules'.DS.$module.DS.'tmpl'.DS.$layout.'.php';
// If the template has a layout override use it
if (file_exists($tPath)) {
return $tPath;
} else {
return $bPath;
}
}
[Edit See Also] Template:SeeAlso:JModuleHelper/getLayoutPath
Examples
<CodeExamplesForm />