To make Joomla! respond appropriately to a request, the application contains a JRouter
object. This object determines the direction to take through the application. This is based on URI query values. To make Joomla! URIs friendlier, it can be set up to use SEF (Search-Engine Friendly) URIs.
In
order to take advantage of SEF URIs, when we render any, we need to use the JRoute::_()
method. This method converts normal URIs into SEF URIs; this will only happen if the component has a router and if the SEO options are enabled. In this example, we parse the URI index.php?option=com_boxoffice&layout=list
into an SEF URI:
echo JRoute::_('index.php?option=com_boxoffice&layout=list');
This is an example of the output we might receive:
http://example.org/joomla/index.php/component/boxoffice/list
The end of the URI, after index.php
, is called the SEF segments. Each segment is separated by a forward slash.
To create a router for a component, we must create a file called router.php
in the...