-
Notifications
You must be signed in to change notification settings - Fork 18
Routing
Routing in MidCOM is based on Topics, which gives you a lot of flexibility in how you structure your site's URL space. If your topic tree looks like this:
root
news
blog
aboutus
company
Then a URL like /news/blog/latest/5/
would be resolved to the topic with the name blog
. At this point, the topic's component takes over, and tries to map the remaining URL (in this case latest/5/
) to a handler inside the component. Which routes can be handled by a component is determined in the routes.inc
file in the component's config
directory. A typical route definition might look like this:
'latest' => array(
'handler' => array('net_nehmer_blog_handler_index', 'index'),
'fixed_args' => 'latest',
'variable_args' => 1,
),
So with the given URL, the handler class net_nehmer_blog_handler_index
would get instantiated, and the method _handler_index
will be called. Everything that matches variable_args
(in this example, 5
) get passed to _handler_index
in the $args
parameter:
public function _handler_index($handler_id, array $args, array &$data)
{
// $handler_id == 'latest'
// $args[0] == '5'
}