沃梦达 / 编程问答 / php问题 / 正文

设置 joomla 组件 router.php

setting joomla component router.php(设置 joomla 组件 router.php)

本文介绍了设置 joomla 组件 router.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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.

这篇关于设置 joomla 组件 router.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:设置 joomla 组件 router.php

基础教程推荐