I am developing a component a component. When i click on a item or enter the URL like this "index.php?view=customercenter&id=31" i receive the id of the item with this code:
Controller:
public function display($cachable = false, $urlparams = false)
{
$document = JFactory::getDocument()->input;
$id = $this->input->get('id', 0, 'INT');
$vName = $this->input->get('view', 'customercenter');
$this->input->set('view', $vName);
parent::display($cachable, $urlparams);
return $this;
}
That works and i recieve the id "31". But when i enable sef-friendly urls and create the router.php, i always get "0"
Router.php:
function CustomerCenterBuildRoute( &$query ) {
$segments = array();
if (isset($query['view']))
{
$segments[] = $query['view'];
unset($query['view']);
}
if (isset($query['id']))
{
$segments[] = $query['id'];
unset($query['id']);
};
return $segments; }
function CustomerCenterParseRoute($segments) {
$vars = array();
switch($segments[0])
{
case 'categories':
$vars['view'] = 'categories';
break;
case 'category':
$vars['view'] = 'category';
$id = explode(':', $segments[1]);
$vars['id'] = (int) $id[0];
break;
case 'article':
$vars['view'] = 'article';
$id = explode(':', $segments[1]);
$vars['id'] = (int) $id[0];
break;
}
return $vars;
}
The link:
<a href='" . JRoute::_('index.php?view=customercenter&id=' . $row->id . ':' . JFilterOutput::stringURLSafe($row->name) ) . "'>" . $row->name . "</a>
Does the method "input->get('id', 0, 'INT');" not work with sef-friendly urls?