2017-08-24 5 views
0

Hallo ich umgesetzt haben gefunden Paginierung in meiner Webseite Klick auf die Paginierung Links bekommen Fehler alsPaginierung funktioniert nicht in codeigniter bekommen 404 Seite nicht

404 Seite nicht gefunden

Die von Ihnen angeforderte Seite wurde nicht gefunden.

Controller:

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); 
    } 
    } 

Modell:

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; 
    } 
} 

Ausblick:

<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> 

Hat gibt es irgendwelche Änderungen brauchen getan weiß nicht, warum es als 404-Seite angezeigt wird nicht gefunden.

es die URL angezeigt wird, wie:

staging.website.com/admin/index.php/blogs Dieses die URL, die ab jetzt angezeigt wird.

+0

Sie müssen möglicherweise einige Routen in routes.php https einstellen : //www.sitepoint.com/pagination-with-codeigniter/ auch brauchen Sie nicht Index in der Basis-URL '$ config [" base_url "] = base_url ('Blog s '); 'andere Funktionen ja, aber nicht Index. – user4419336

+0

@ wolfgang1983 nicht bekommen Sie, was Sie sagen – user8001297

Antwort

1

gelöst, indem Sie den Code in diesem Format Hinzufügen

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

den folgenden Code ändern

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

und auch

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

bekommen den gleichen Fehler nach der Änderung auch – user8001297

Verwandte Themen