JApplication/getRouter: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Returns the application JRouter object.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<no... |
No edit summary |
||
| Line 1: | Line 1: | ||
===Description=== | ===Description=== | ||
Return a reference to the application JRouter object. | |||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
| Line 9: | Line 9: | ||
===Syntax=== | ===Syntax=== | ||
<source lang="php"> | <source lang="php">& getRouter($name=null, $options=array())</source> | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 21: | Line 21: | ||
| $options An optional associative array of configuration settings. | | $options An optional associative array of configuration settings. | ||
|- | |- | ||
| | | $options | ||
| array() | | array() | ||
| | | | ||
| Line 36: | Line 36: | ||
===Source Body=== | ===Source Body=== | ||
<source lang="php"> | <source lang="php"> | ||
function &getRouter($name = null, $options = array()) | |||
{ | { | ||
if (!isset($name)) { | if(!isset($name)) { | ||
$name = $this->_name; | $name = $this->_name; | ||
} | } | ||
jimport('joomla.application.router'); | jimport( 'joomla.application.router' ); | ||
$router = &JRouter::getInstance($name, $options); | $router =& JRouter::getInstance($name, $options); | ||
if (JError::isError($router)) { | if (JError::isError($router)) { | ||
return null; | $null = null; | ||
return $null; | |||
} | } | ||
return $router; | return $router; | ||
Revision as of 22:09, 22 March 2010
Description
Return a reference to the application JRouter object.
Template:Description:JApplication/getRouter
Syntax
& getRouter($name=null, $options=array())
| Parameter Name | Default Value | Description |
|---|---|---|
| $name | null | $options An optional associative array of configuration settings. |
| $options | array() |
Returns
.
Defined in
libraries/joomla/application/application.php
Importing
jimport( 'joomla.application.application' );
Source Body
function &getRouter($name = null, $options = array())
{
if(!isset($name)) {
$name = $this->_name;
}
jimport( 'joomla.application.router' );
$router =& JRouter::getInstance($name, $options);
if (JError::isError($router)) {
$null = null;
return $null;
}
return $router;
}
[Edit See Also] Template:SeeAlso:JApplication/getRouter
Examples
<CodeExamplesForm />