I am working on joomla 3.X and i have create component custom.
Here is its link how the custom component page is open : http://joomlavogueteamdemo.com.bh-in-7.webhostbox.net/petitions-new/view-petitions/ireland/LuasOn
Here Petition-new is component name View-Petitions is Petition View
We want its short url like: http://joomlavogueteamdemo.com.bh-in-7.webhostbox.net/petitions-new/ireland/LuasOn
Here we have attached our router.php code also.
function petitionsBuildRoute(&$query)
{
print_r($query);
if($query['Itemid'] != '487'){
$segments = array();
if (isset($query['view']))
{
$segments[] = $query['view'];
unset($query['view']);
}
if (isset($query['id']))
{
$segments[] = $query['id'];
unset($query['id']);
}
if (isset($query['pid']))
{
$segments[] = $query['pid'];
unset($query['pid']);
};
if (isset($query['name']))
{
$segments[] = $query['name'];
unset($query['name']);
};
return $segments;
}else{
$segments = array();
return $segments;
}
}
function petitionsParseRoute($segments)
{
$vars = array();
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getActive();
if($segments[0] == 'Ireland'){
$vars['view'] = 'Ireland';
$vars['name'] = $segments[1];
//name to get id
$db = JFactory::getDbo();
$query = "SELECT `id` FROM `#__petitions_signataires` WHERE `ref` = '$segments[1]'";
$db->setQuery($query);
$row = $db->loadRow();
$pid= $row[0];
$vars['pid'] = (int) $pid;
return $vars;
}
switch($item->query['view'])
{
case 'categories':
$vars['view'] = 'categories';
break;
case 'category_petition':
if($segments[0] == 'detail_petition'){
$vars['view'] = 'detail_petition';
$id = $segments[1];
$vars['id'] = (int) $id ;
}elseif($segments[0] == 'Ireland'){
$vars['view'] = 'Ireland';
$vars['name'] = $segments[1];
//name to get id
$db = JFactory::getDbo();
$query = "SELECT `id` FROM `#__petitions_signataires` WHERE `ref` = '$segments[1]'";
$db->setQuery($query);
$row = $db->loadRow();
$pid= $row[0];
$vars['pid'] = (int) $pid;
}
break;
case 'article':
//$vars['view'] = 'article';
$id = $segments[0];
$vars['pid'] = (int) $id[0];
$vars['latestnews'] = 'latest';
$vars['detailslink'] = 'link';
break;
case 'com_petitions':
$vars['view'] = 'id';
$id = $segments[0];
$vars['id'] = $id[0];
break;
}
return $vars;
}
So please help us here to resolve this single issue in my job.
Regards, Urjit