设置 joomla 组件 router.php

2022-01-06 00:00:00 php joomla

我正在使用 joomla 1.5 并构建一个简单的组件,用于浏览美国的州和城市.问题出现在我的 router.php 文件中.我的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 $vars;
}

问题在于,我已经获得了所需的 url,[menualias]/[state].html,但是当我转到该页面时,显示未找到对象的页面.谁能帮我.我的 router.php 有什么问题

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

推荐答案

请检查 url 中的项目 ID,我正在发送我的代码.按照我的代码并创建您的路由器文件.

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.

相关文章