SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 138 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"


Chapter 4
[ 101 ]
To create a router for a component we must create a file called router.php in the
root of the component. In the file we need to define two functions, BuildRoute()
and ParseRoute(), both prefixed with the name of our component. These functions
build and parse between a URI query and an array of SEF segments.
The BuildRoute() function is used to build an array of SEF segments. The function
is passed an associative array of URI query values.
This is an example of the BuildRoute() function that we might have been using
in the previous example. We must return the array of data segments in the order
they will appear in the SEF URI. We must remove any elements from the referenced
$query associative array parameter; any elements we do not remove will be
appended to the end of the URI in query format. For example, if we passed the value
'index.php?option=com_myExtension& category=3&item=6&foo=bar' to the
JRoute::_() method, we would get the route:
http://example.org/joomla/index.php/component/myExtension/3/6?foo=bar.


Pages:
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150