2017-08-24 15 views
0

こんにちは、私はあなたが要求したページが見つかりませんでしたページネーションは、404ページ

が見つかりません

404ページとしてエラーを取得してページネーションリンク上で私のWebページのクリックでページネーションを実装しているが見つからないばかりCodeIgniterの中で働いていません。

コントローラー:

class Blogs extends CI_Controller 
{ 
function __construct() 
    { 
     parent::__construct(); 
     $this->load->library('session'); 
     $this->load->library('form_validation'); 
     $this->load->library("pagination"); 
     $this->load->model('blogs_model'); 
     if($this->session->userdata('admin_logged_in')){ 
      $this->data['admin_details'] = $this->session->userdata('admin_logged_in'); 
     } 
     else{ 
      redirect('welcome'); 
     } 
    } 

function index() 
    { 
    $config = array(); 
    $config["base_url"] = base_url() . "blogs/index"; 
    $config["total_rows"] = $this->blogs_model->record_count(); 
    $config["per_page"] = 11; 
    $config["uri_segment"] = 4; 
    $this->pagination->initialize($config); 
    $page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0; 
    $data['records'] = $this->blogs_model->get_blogs($config["per_page"], $page);   
    $data["links"] = $this->pagination->create_links(); 
    $data['mainpage']='blogs'; 
    $data['mode']='all'; 
    $this->load->view('templates/template',$data); 
    } 
    } 

モデル:

function get_blogs($limit, $start) 
{ 
    $this->db->limit($limit, $start); 
    $this->db->Select('blogs.*'); 
    $this->db->From('blogs'); 
    $this->db->where(array('blogs.status'=>1)); 
    $this->db->order_by("date", "desc"); 
    $q=$this->db->get(); 
    if($q->num_rows()>0)  
    {  
     return $q->result(); 
    } 
    else 
    { 
     return false; 
    } 
} 

ビュー:

<div id="main">   
     <div class="full_w"> 
      <div class="h_title"> 
       <div class="lefttitle fl"> 
        Blogs 
       </div> 
       <div class="rightbutton fr"> 
        <a class="button add" href="<?php echo site_url();?>/blogs/add">Add </a> 
        <a class="button add" href="<?php echo site_url();?>/category">Category </a> 
        <a class="button del" href="<?php echo site_url();?>/blogs/deactivated">Deactivated Blogs</a>      
       </div> 
      </div> 
      <table> 
       <thead> 
        <tr> 
         <th scope="col">Featured Blogs</th> 
         <th scope="col">S.No</th> 
         <th scope="col">Blog Title</th> 
         <th scope="col">Author</th> 
         <th scope="col">Comments</th>        
         <th scope="col">Date</th> 
         <th scope="col">Hits</th> 
         <th scope="col" style="width: 65px;">Modify</th> 
        </tr> 
       </thead> 

       <tbody> 

       <?php if(isset($records) && is_array($records) && count($records)>0): ?>  
       <?php $i=0;foreach($records as $r):$i++;?>  
        <tr> 
         <td><input type="checkbox" name="checkbox" value="<?php echo $r->blog_id;?>"></td>       
         <td class="align-center"><?php echo $i;?></td> 
         <td><?php echo $r->blog_title;?></td> 
         <td><?php echo $r->username;?></td> 
         <td><span data-plugin="comment-count"><?php echo $comments;?></span></td> 
         <td><?php echo $r->date;?></td> 
         <td><?php echo $r->ne_views;?></td> 
         <td> 
          <a href="<?php echo site_url();?>/blogs/edit/<?php echo $r ->blog_id ;?>" class="table-icon edit" title="Edit"></a> 
          <a href="<?php echo site_url();?>/blogs/delete/<?php echo $r ->blog_id ;?>" onclick="return confirm('Are you sure to delete');" class="table-icon delete" title="Delete"></a> 
         </td> 
        </tr> 

       <?php endforeach ;endif;?> 

       </tbody> 
      </table> 
      <p><?php echo $links; ?></p> 
      <button id="someButton">Activate</button> 
</button> 
     </div> 
    </div> 
    <div class="clear"></div> 

は、すべての変更は、それが404ページとして表示している理由を知りません完了する必要がありますん見つかりません。

としては、URLが表示されます。これは、今のところ、表示されたURLであるstaging.website.com/admin/index.php/blogs

+0

あなたはroutes.phpのHTTPSでいくつかのルートを設定する必要があるかもしれません://www.sitepoint.com/pagination-with-codeigniter/ base URLにindexを使う必要もない '$ config [" base_url "] = base_url( 'blog s ');他の関数はありますが、インデックスはありません。 – user4419336

+0

@ wolfgang1983あなたが何を言っているのかわからない – user8001297

答えて

1
この形式でコードを追加することで解決

$config = array(); 
    $config["base_url"] = base_url("index.php/blogs/index"); 
0

変更次のコードを

$config["base_url"] = base_url("blogs/index"); 
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; 

とも

$config["uri_segment"] = 3; 
+0

変更後も同じエラーが発生する – user8001297

関連する問題