Actions

Difference between revisions of "JModuleHelper/getLayoutPath"

From Joomla! Documentation

(New page: {{review}} ===Syntax=== ''string'' getLayoutPath ($module, [$layout = 'default']) where: {| class="wikitable" !Argument !Data type !Description !Default |- |$module |string |The name o...)
 
(Reviewed and improved.)
 
Line 1: Line 1:
{{review}}
+
This method returns the path to the layout file for the module.  It checks if there is a layout override in the 'html' folder of the template (See: [[How to override the output from the Joomla! core]]). If there is, it returns the path to the override file; otherwise it returns the path to the original layout file.  Note that, unlike other JModuleHelper methods, you must include the 'mod_' prefix here.  If the module does not exist the path to the layout file will still be returned.
 
===Syntax===
 
===Syntax===
''string''   getLayoutPath ($module, [$layout = 'default'])
+
''string'' getLayoutPath( $module, $layout )
  
 
where:
 
where:
Line 12: Line 12:
 
|$module
 
|$module
 
|string
 
|string
|The name of the module
+
|The name/type of the module.  You must include the 'mod_' prefix here.
 
|
 
|
 
|-
 
|-
 
|$layout
 
|$layout
 
|string
 
|string
|The name of the layout to be loaded
+
|The name of the layout.
|default
+
|'default'
 
|}
 
|}
=== What does this method do? ===
 
This method returns the path to the layout file of the module. It checks if there has been a template override in the 'html' folder of the template (See: [[How to override the output from the Joomla! core]]). If there is, it returns the path to the template override file, else it returns the path to the original layout file.
 
 
 
===Example===
 
===Example===
Let's try to get the the layout path of the mod_feed Module of Joomla.
+
Determine the path to the layout of the mod_feed module.
 
<source lang="php">
 
<source lang="php">
jimport('joomla.application.module.helper');
+
jimport( 'joomla.application.module.helper' );
echo JModuleHelper::getLayoutPath('mod_feed');
+
echo JModuleHelper::getLayoutPath( 'mod_feed' );
/* RESULT:
+
/htdocs/modules/mod_feed/tmpl/default.php
+
*/
+
 
</source>
 
</source>
 +
If the layout has not been overridden this might output:
 +
<pre>/htdocs/modules/mod_feed/tmpl/default.php
 +
</pre>
 
===See also===
 
===See also===
 +
* [http://api.joomla.org/Joomla-Framework/Application/JModuleHelper.html#getLayoutPath JModuleHelper::getLayoutPath on api.joomla.org]
 
* [[How to override the output from the Joomla! core]]
 
* [[How to override the output from the Joomla! core]]
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JModuleHelper]]</noinclude>
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JModuleHelper]]</noinclude>

Latest revision as of 15:16, 7 February 2009

This method returns the path to the layout file for the module. It checks if there is a layout override in the 'html' folder of the template (See: How to override the output from the Joomla! core). If there is, it returns the path to the override file; otherwise it returns the path to the original layout file. Note that, unlike other JModuleHelper methods, you must include the 'mod_' prefix here. If the module does not exist the path to the layout file will still be returned.

Syntax

string getLayoutPath( $module, $layout )

where:

Argument Data type Description Default
$module string The name/type of the module. You must include the 'mod_' prefix here.
$layout string The name of the layout. 'default'

Example

Determine the path to the layout of the mod_feed module.

jimport( 'joomla.application.module.helper' );
echo JModuleHelper::getLayoutPath( 'mod_feed' );

If the layout has not been overridden this might output:

/htdocs/modules/mod_feed/tmpl/default.php

See also