我正在使用joomla 1.5并构建一个简单的组件来为美国的州和城市提供服务。我的router.php文件中出现了问题。我的router.php如下
function DesignBuildRoute(&$query)
{
$segments = array();
if(isset($query['task']))
{
$segments[] = $query['task'];
unset($query['task']);
};
if(isset($query['state']))
{
$segments[] = $query['state'];
unset($query['state']);
};
return $segments;
}
function DesignParseRoute($segments)
{
$vars = array();
$vars['task'] = $segments[0];
$vars['state'] = $segments[1];
return $vars;
}
问题在于,我已经获得了所需的网址,[menualias] / [state] .html,但是当我转到该页面时,会显示找不到对象的页面。谁能帮我。我的router.php有什么问题
答案 0 :(得分:1)
请检查网址中的商品ID,然后发送我的代码。关注我的代码并创建路由器文件。
function demoBuildRoute(&$query) {
$segments = array();
if (isset($query['view'])) {
$segments[] = $query['view'];
unset($query['view']);
}
if (isset($query['link_id'])) {
$segments[] = $query['link_id'];
unset($query['link_id']);
}
if (isset($query['Itemid'])) {
$segments[] = $query['Itemid'];
unset($query['Itemid']);
}
return $segments;
}
function demoParseRoute($segments) {
$vars = array();
$count = count($segments);
if ($count == '1')
{
$vars['view'] = $segments[0];
$vars['Itemid'] = $segments[1];
}
if ($count == '2')
{
$vars['view'] = $segments[0];
$vars['Itemid'] = $segments[1];
}
if ($count == '3')
{
$vars['view'] = $segments[0];
$vars['Itemid'] = $segments[2];
}
return $vars;
}
检查你的网址并创建路由器文件。