ok i got my custom component router, but i still need the values inside it and i dont know how can i use these values in my component
for example in the url
index.php?option=com_maodeobras&view=maodeobras&cat=mymaincat&sub=mysubcat
i want the desired result (achieved with my router)
maodeobras/mymaincat/mysubcat.html
the question is:
how can i retrieve the variables cat and sub from the component or url?
here's my router
function MaodeobrasBuildRoute(&$query)
{
$segments = array();
if(isset($query['view'])):
$segments[] = $query['view'];
unset($query['view']);
endif;
if(isset($query['id'])):
$segments[] = $query['id'];
unset($query['id']);
endif;
if(isset($query['cat'])):
$segments[] = $query['cat'];
unset($query['cat']);
endif;
if(isset($query['sub'])):
$segments[] = $query['sub'];
unset($query['sub']);
endif;
return $segments;
}
function MaodeobrasParseRoute($segments)
{
$vars = array();
$app =& JFactory::getApplication();
$menu =& $app->getMenu();
$item =& $menu->getActive();
// Count segments
$count = count($segments);
//Handle View and Identifier
switch($segments[0])
{
case 'maodeobras':
//if ($count == 1) {
$id = explode(':', $segments[$count-1]);
$vars['id'] = (int) $id[0];
$vars['view'] = 'maodeobras';
//}
break;
case 'categoriasdemãodeobras':
$id = explode(':', $segments[$count-1]);
$vars['id'] = (int) $id[0];
$vars['view'] = 'categoriasdemãodeobras';
break;
case 'madeobrasfiltros':
$id = explode(':', $segments[$count-1]);
$vars['id'] = (int) $id[0];
$vars['view'] = 'madeobrasfiltros';
break;
case 'subcategorias':
$id = explode(':', $segments[$count-1]);
$vars['id'] = (int) $id[0];
$vars['view'] = 'subcategorias';
break;
}
return $vars;
}