无法为组件joomla 2.5定制路由器

时间:2014-04-23 08:56:26

标签: php joomla

我有自定义路由器,所以它可以按以下格式给我网址。

<i>/menueItem/componentName/viewName/id-title-of-page.html</i>

在页面上我写了

<i>JRoute::_('index.php?option=com_exl_case_studies&view=casestudies&Itemid=165&p=' . $item->id .'title=' writeAlias($item->title, $aliasLength));</i>

我无法弄清楚我应该在router.php中写什么来实现这个目标。这是我的router.php

<i>

function Exl_case_studiesBuildRoute(&amp; $ query) {     $ segments = array();

if (isset($query['task'])) {
    $segments[] = implode('/',explode('.',$query['task']));
    unset($query['task']);
}
if (isset($query['id'])) {
    $segments[] = $query['id'];
    unset($query['id']);
}

return $segments;

}

function Exl_case_studiesParseRoute($segments)

{     $ vars = array();

// view is always the first element of the array
$count = count($segments);

if ($count)
{
    $count--;
    $segment = array_pop($segments) ;
    if (is_numeric($segment)) {
        $vars['id'] = $segment;
    }
    else{
        $count--;
        $vars['task'] = array_pop($segments) . '.' . $segment;
    }
}

if ($count)
{   
    $vars['task'] = implode('.',$segments);
}


return $vars;

}

0 个答案:

没有答案