JRouter

From Joomla! Documentation
(Difference between revisions)
Jump to: navigation, search
m
Line 9: Line 9:
 
===Extends===
 
===Extends===
 
* [[JObject]]
 
* [[JObject]]
 +
 +
===Get and Set Methods===
 +
Properties which do not have specific get or set methods listed here can be retrieved or set using the inherited [[JObject/get|JObject->get]] method.
 +
{| class="wikitable"
 +
|-
 +
!Get method
 +
!Set method
 +
!Description
 +
!Property
 +
|-
 +
|[[JRouter/getMode|getMode]]
 +
|[[JRouter/setMode|setMode]]
 +
|Give access to the router mode
 +
|<code>$router->_mode</code>
 +
|-
 +
|[[JRouter/getVar|getVar]]
 +
|[[JRouter/setVar|setVar]]
 +
|Give access to router variables
 +
|<code>$router->_vars[$key]</code>
 +
|-
 +
|[[JRouter/getVars|getVars]]
 +
|[[JRouter/setVars|setVars]]
 +
|Get and set router variables
 +
|<code>$router->_vars</code>
 +
|}
  
 
===Methods===
 
===Methods===
Line 15: Line 40:
 
!Method name
 
!Method name
 
!Description
 
!Description
 +
|-
 +
|[[JRouter/__construct|__construct]]
 +
|Constructor
 +
|-
 +
|[[JRouter/attachBuildRule|attachBuildRule]]
 +
|Adds a callback function to the stack of build rules
 +
|-
 +
|[[JRouter/attachParseRule|attachParseRule]]
 +
|Adds a callback function to the stack of parse rules
 +
|-
 +
|[[JRouter/build|build]]
 +
|Converts an internal URI to a route. See also the [[JRouter/parse|parse]] method.
 +
|-
 +
|[[JRouter/getInstance|getInstance]]
 +
|Returns a reference to the global JRouter object, only creating it if it doesn't already exist
 +
|-
 +
|[[JRouter/getMode|getMode]]
 +
|Get the router mode
 +
|-
 +
|[[JRouter/parse|parse]]
 +
|Converts a route to an internal URI. See also the [[JRouter/build|build]] method.
 +
|-
 +
 +
|-
 
|}
 
|}
 
===Importing===
 
===Importing===
 
<source lang="php">jimport( 'joomla.application.router' );</source>
 
<source lang="php">jimport( 'joomla.application.router' );</source>
  
===JRouter, the Joomla CMS and writing your own components===
+
===JRouter, the Joomla CMS and writing your own SEO components===
 
JRouter is an abstract class of the ''Joomla Framework''. The ''Joomla CMS'' is a concrete application, using the Joomla Framework. Thus, they have created their own concrete Router class, which handles routes. This concrete Router is called '''JRouterSite''' and can be found in <code>includes/router.php</code>.  
 
JRouter is an abstract class of the ''Joomla Framework''. The ''Joomla CMS'' is a concrete application, using the Joomla Framework. Thus, they have created their own concrete Router class, which handles routes. This concrete Router is called '''JRouterSite''' and can be found in <code>includes/router.php</code>.  
  

Revision as of 03:13, 9 August 2009

JRouter is an abstract class to create an parse routes. You need to write your own concrete Router Class to make use of its functionality. The Joomla CMS uses the JRouterSite class as concrete Router implementation. For further information see below.

Contents

Availability

From Joomla 1.5 Joomla 1.6

Defined in

/joomla/application/router.php

Extends

Get and Set Methods

Properties which do not have specific get or set methods listed here can be retrieved or set using the inherited JObject->get method.

Get method Set method Description Property
getMode setMode Give access to the router mode $router->_mode
getVar setVar Give access to router variables $router->_vars[$key]
getVars setVars Get and set router variables $router->_vars

Methods

Method name Description
__construct Constructor
attachBuildRule Adds a callback function to the stack of build rules
attachParseRule Adds a callback function to the stack of parse rules
build Converts an internal URI to a route. See also the parse method.
getInstance Returns a reference to the global JRouter object, only creating it if it doesn't already exist
getMode Get the router mode
parse Converts a route to an internal URI. See also the build method.

Importing

jimport( 'joomla.application.router' );

JRouter, the Joomla CMS and writing your own SEO components

JRouter is an abstract class of the Joomla Framework. The Joomla CMS is a concrete application, using the Joomla Framework. Thus, they have created their own concrete Router class, which handles routes. This concrete Router is called JRouterSite and can be found in includes/router.php.

If you take a look at the private _buildSefRoute method of this class, you'll quickly realise that the Joomla Developers allow you to create your own custom routing handlers for each of your components. This way, you can make your components SEO friendly. If you want to learn, how to write such an handler take a look at this article and visit the section The Component Router

See also

Personal tools
Namespaces

Variants
Actions
Navigation
Joomla! Sites
Toolbox