2016-06-14 5 views
-1

Ich habe eine Abfrage, um alle Benutzer auf meiner Webseite anzuzeigen. Wir haben rund 327 Benutzer. und ich möchte Paginierung verwenden. aber ich kann nicht herausfinden, wie ich das in meinem eigenen Code verwenden kann.Verwendung von Paginierung | CodeIgniter |

Das ist mein Controller-

<?php 


class alluser extends MY_Controller { 



    function __construct() { 


     parent::__construct(); 

     $this->load->helper('date'); 

     $this->load->helper('file'); 

     $this->load->helper('dir'); 

     $this->load->model('user_model'); 

     $this->load->model('inspiration_model'); 

     $this->load->model('notes_model'); 

     $this->load->library('pagination'); 
     $config['total_rows'] = 300; 
     $config['per_page'] = 20; 
     $this->pagination->initialize($config); 
     echo $this->pagination->create_links(); 

     $this->data['head']['stylesheets'][] = 'onestowatch/onestowatch.min.css'; 

     $this->data['head']['javascripts'][] = 'shuffle/jquery.shuffleLetters.min.js'; 

     $this->data['head']['javascripts'][] = 'custom/app/onestowatch.min.js'; 

     if (!logged_in()) { 

      redirect('login'); 

     } 

    } 


    public function index(){ 

    $user_id = $this->data['user']['user_id']; 

    $now = time(); 



    $designments = $this->user_model->get_my_running_designments_by_id($user_id, $now); 



    foreach ($designments as &$designment) { 

     $designment['inspiration_count'] = $this->inspiration_model->get_inspiration_count_for_user_by_id($designment['designment_id'], $user_id); 

     $designment['note_count'] = $this->notes_model->get_notes_count_for_user_by_id($designment['designment_id'], $user_id); 

    } 



    $this->data['my_designments'] = $designments; 



    $this->data['user_info'] = $this->user_model->get_user_info_by_user_id($user_id); 

    $this->data['user_info']['user_icon'] = $this->user_model->get_big_user_icon_by_id($user_id); 

    $this->data['onestowatch'] = $this->user_model->get_ones_to_watch(1000); 

    $this->template->load('templates/template_view', 'app/alluser/view', $this->data); 

} 

Das ist meine Ansicht ist:

<script type="text/javascript"> 
    var onestowatch = <?= json_encode($onestowatch) ?>; 
</script> 

<section id="list" class="w940 fl"> 
    <p class="clearfix"><span class="bg-white ff-b orange f28 title-1 fl shadow">All users</span></p> 
</section> 


<script type="text/x-mustache" id="onetowatch"> 
    <dl style="margin-top: 20px;"> 
    <dd> 
    <div class="onetowatch shadow"> 
    <img class="user_icon" src="<?= site_url('') ?>{{image}}"> 
    <div class="fl ff-l f18 shuffle">{{fullname}}</div> 
    </div> 
    </dd> 
    </dl> 
</script> 

und Modell query:

function get_ones_to_watch($limit, $smallicon = false) { 
     $this->db->select('user_to_designment.user_id, count(user_to_designment.user_id) as designment_joined, user_profiles.first_name, user_profiles.middle_name, user_profiles.last_name, user_profiles.date_of_birth'); 
     $this->db->from('user_to_designment'); 
     $this->db->join('user_to_user_profile', 'user_to_designment.user_id = user_to_user_profile.user_id'); 
     $this->db->join('user_profiles', 'user_to_user_profile.profile_id = user_profiles.profile_id'); 
     $this->db->group_by('user_id'); 
     $this->db->order_by('designment_joined', 'desc'); 
     $this->db->limit($limit); 

     $onestowatch = $this->db->get()->result_array(); 

     foreach ($onestowatch as &$onetowatch) { 
      if($smallicon){ 
       $onetowatch['image'] = self::get_small_user_icon_by_id($onetowatch['user_id']); 
      }else{ 
       $onetowatch['image'] = self::get_big_user_icon_by_id($onetowatch['user_id']); 
      } 
     } 

     return $onestowatch; 
    } 

Vielen Dank für jede Hilfe erhalten i!

Antwort

0

können Sie den folgenden Link finden Paginierung https://ellislab.com/codeigniter/user-guide/libraries/pagination.html

+0

ja bereits, dass gefunden zu schaffen, aber es hat mir nicht geholfen. – keescavia

+0

Ich habe Tutorial über Cdeigniter Paginierung geschrieben. Bitte werfen Sie einen Blick und geben Sie Ihre Vorschläge https://www.cloudways.com/blog/pagination-in-codeigner/ –