简体   繁体   English

分页路由代码点火器不工作404错误

[英]pagination route code igniter not working 404 error

public function add_template(){
 $this->load->library('pagination');
     $config = array();
     $config['base_url'] =site_url('hradmin/dashboard/add_template');
     $config['total_rows'] = $this->hradvalid->add_temprow();
     $config['per_page'] = 2;
     $config['use_page_numbers'] = TRUE;
     $config['uri_segment']  = 4;
     $config['full_tag_open'] = "<ul class='pagination pagination-sm1>";
     $config['full_tag_close'] = '</ul>';
     $config['first_tag_open'] = '<li>';
     $config['first_tag_close'] = '</li>';
     $config['last_tag_open'] = '<li>';
     $config['last_tag_close'] = '</li>';
     $config['num_tag_open'] = '<li>';
     $config['num_tag_close'] = '</li>';
     $config['prev_tag_open'] = '<li>';
     $config['prev_tag_close'] = '</li>';
     $config['next_tag_open'] = '<li>';
     $config['next_tag_close'] = '</li>';
     $config['cur_tag_open'] = "<li class='active'><a>";
     $config['cur_tag_close'] = '</a></li>';
     $this->pagination->initialize($config); 

    $data['page']="hradmin/add_template";
    $data['template']=$this->hradvalid->hrget_product($config['per_page'],$this->uri->segment(4));
    $this->load->view('hradmin/dashboard',$data);
     }

this is route code in config/routes.php 这是config/routes.php路由代码

  `$route['hradmin'] = 'hradmin/admin';
  $route['hradmin/admin/dashboard/add_template:num'] ='hradmin/admin/dashboard/add_template/$1';`

hradmin this is my directory name in views directory hradmin这是views目录中的目录名

admin this is my controller dashboard this is method in admin controller and another method in same controller is add template in this method my pagination file are there. admin这是我的控制器dashboard这是admin控制器中的方法,同一个控制器中的另一个方法是在这个方法中add template我的分页文件就在那里。

pagination working showing but click on pagination number error 404 please help me thanks 分页工作显示但点击分页号码错误404请帮助我谢谢

I'd start with drilling down your URI segments to make sure they're right but here are some things i've noticed with your code. 我首先深入挖掘您的URI段以确保它们是正确的,但这里有一些我已经注意到的代码。

  1. You don't need to set the $config variable as an array. 您不需要将$ config变量设置为数组。 ( $config = array(); ) - you can remove that line. $config = array(); ) - 您可以删除该行。

  2. $config['total_rows'] = $this->hradvalid->add_temprow(); ... the function name looks like its adding a row. ...函数名称看起来像添加一行。 $config['total_rows'] should be an interger with the total available rows. $ config ['total_rows']应该是一个具有总可用行的整数。

  3. You're setting the base_url as site_url('hradmin/dashboard/add_template') but your routes are for site_url(hradmin/admin/dashboard/add_template:num) (extra admin URI segment). 您将base_url设置为site_url('hradmin/dashboard/add_template')但您的路由是针对site_url(hradmin/admin/dashboard/add_template:num) (额外的管理员URI段)。

  4. use (:num) in your routing instead of :num 在路由中使用(:num)而不是:num

EDIT, If I had to take a stab at this, i'd say your $config['base_url'] and $config['uri_segment'] var's, along with your routing params, are incorrect. 编辑,如果我不得不采取刺,我会说你的$ config ['base_url']和$ config ['uri_segment'] var,以及你的路由参数,是不正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM