How to use alias in route.php? - Joomla! Forum - community, help and support
hello,
so here's route.php:
and works good!
the url gets like: /menu-item-name/item/id
but how can use alias? tried digging com_content didn't see use of alias there, how did make automatically?
i want /menu-item-name/item/alias
so here's route.php:
code: select all
function componentbuildroute(&$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 componentparseroute($segments)
{
$vars = array();
$vars['view'] = $segments[0];
if (count($segments) > 1)
{
$vars['id'] = $segments[1];
}
return $vars;
}
and works good!
the url gets like: /menu-item-name/item/id
but how can use alias? tried digging com_content didn't see use of alias there, how did make automatically?
i want /menu-item-name/item/alias
this interesting... could'nt find reference article alias in com_content router too...
but this:
- add alias field table
- generate alias when data being saved
- inside router, create function getalias return data alias based on table , key_name , key_value
- call getalias inside build route function
- inside router, create function getkey return data key value based on table, alias , key_name.
- call getkey inside parse route function
and it...
m4rc0 wrote:hello,
so here's route.php:code: select all
function componentbuildroute(&$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 componentparseroute($segments)
{
$vars = array();
$vars['view'] = $segments[0];
if (count($segments) > 1)
{
$vars['id'] = $segments[1];
}
return $vars;
}
and works good!
the url gets like: /menu-item-name/item/id
but how can use alias? tried digging com_content didn't see use of alias there, how did make automatically?
i want /menu-item-name/item/alias
but this:
- add alias field table
- generate alias when data being saved
- inside router, create function getalias return data alias based on table , key_name , key_value
- call getalias inside build route function
- inside router, create function getkey return data key value based on table, alias , key_name.
- call getkey inside parse route function
and it...
Comments
Post a Comment