setting joomla component router.php
I am using joomla 1.5 and building a simple component for sfowing the states and cities of USA. The problem has arrised in my router.php file. My router.php is as follows
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 $va开发者_运维百科rs;
}
the problem is this, that i have got the required url, [menualias]/[state].html, but when I go to the page, object not found page is displayed. Can anyone help me. what is wrong with my router.php
Please check Item id in url and i am sending my code .follow my code and create you router file .
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;
}
Check ur url and create router file.
精彩评论