0
有人能告訴我如何將段添加到海基會網址的開頭 - 即:的Joomla 3.0組件 - 路由器SEF,添加細分
http://somedomain.com/*SEGMENT*/task/id
的*段*只是一個靜態字符串,僅用於顯示,不從查詢中獲取。
我有一個非常基本的router.php在我的組件:
function MyComponentBuildRoute(&$query)
{
$segments = array();
if (isset($query['task'])) {
$segments[] = $query['task'];
unset($query['task']);
}
if (isset($query['id'])) {
$segments[] = $query['id'];
unset($query['id']);
}
return $segments;
}
function MyComponentParseRoute($segments)
{
$vars = array();
$count = count($segments);
if ($count) {
$count--;
$segment = array_shift($segments);
if (is_numeric($segment)) {
$vars['id'] = $segment;
} else {
$vars['task'] = $segment;
}
}
if ($count) {
$count--;
$segment = array_shift($segments) ;
if (is_numeric($segment)) {
$vars['id'] = $segment;
}
}
return $vars;
}
希望有人能幫助!