用户
 找回密码
 入住 CI 中国社区
搜索
查看: 5821|回复: 3
收起左侧

今天来发一个uri传递多个参数分页的方法(不用GET)

[复制链接]
发表于 2009-5-28 23:45:16 | 显示全部楼层 |阅读模式
今天来发一个uri传递多个参数的方法
是小弟我自个研究的,方法很简单.老大们赐教!

直接修改 system\libraries\Pagination.php 文件

从183行开始修改:

PHP复制代码
  // 我加的多个参数链接的方法-------
  $Uristr = '';
  $URLStr = count(explode('/',$_SERVER['REQUEST_URI']));
  $URLArray = explode('/',$_SERVER['REQUEST_URI']);
  $URLConfig = count(explode('/',$this->base_url));
 
  //print_r($URLStr);
  if($URLStr>=$URLConfig){
   for($i=$URLConfig+1;$i<=$URLStr;$i++){
    $Uristr.= "/".$URLArray[$i-1];
   }
  }
  // Render the "First" link
  if  ($this->cur_page > ($this->num_links + 1))
  {
   $output .= $this->first_tag_open.'<a href="'.$this->base_url.$Uristr.'">'.$this->first_link.'</a>'.$this->first_tag_close;
  }
  // Render the "previous" link
  if  ($this->cur_page != 1)
  {
   $i = $uri_page_number - $this->per_page;
   if ($i == 0) $i = 0;
   $output .= $this->prev_tag_open.'<a href="'.$this->base_url.$i.$Uristr.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
  }
  // Write the digit links
  for ($loop = $start -1; $loop <= $end; $loop++)
  {
   $i = ($loop * $this->per_page) - $this->per_page;
     
   if ($i >= 0)
   {
    if ($this->cur_page == $loop)
    {
     $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page
    }
    else
    {
     $n = ($i == 0) ? 0 : $i;
     $output .= $this->num_tag_open.'<a href="'.$this->base_url.$n.$Uristr.'">'.$loop.'</a>'.$this->num_tag_close;
    }
   }
  }
  // Render the "next" link
  if ($this->cur_page < $num_pages)
  {
   $output .= $this->next_tag_open.'<a href="'.$this->base_url.($this->cur_page * $this->per_page).$Uristr.'">'.$this->next_link.'</a>'.$this->next_tag_close;
  }
  // Render the "Last" link
  if (($this->cur_page + $this->num_links) < $num_pages)
  {
   $i = (($num_pages * $this->per_page) - $this->per_page);
   $output .= $this->last_tag_open.'<a href="'.$this->base_url.$i.$Uristr.'">'.$this->last_link.'</a>'.$this->last_tag_close;
  }
复制代码


接下来就可以  /Article/page/15/5/5/6/7/8 多个参数分页了
发表于 2009-7-11 17:41:14 | 显示全部楼层
赞一个!!!
不过太麻烦了!!!!!!
发表于 2009-8-3 16:16:00 | 显示全部楼层
你的代码那么长,我是新手看不下去啊,能说得简单点吗?
发表于 2010-4-7 14:20:50 | 显示全部楼层
今天来发一个uri传递多个参数的方法
是小弟我自个研究的,方法很简单.老大们赐教!

直接修改 system\librari ...
lihao812 发表于 2009-5-28 23:45



    使用这个方法如果参数是中文怎么处理啊(目前会报错)??

本版积分规则