php 使用 codeigniter 进行引导 3 分页

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20088779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:51:58  来源:igfitidea点击:

bootstrap 3 pagination with codeigniter

phpcodeignitertwitter-bootstrappaginationtwitter-bootstrap-3

提问by CaffeineShots

I cant integrate the bootstrap 3 in my pagination, I am using codeigniter in my system, here is my code so far

我无法在我的分页中集成 bootstrap 3,我在我的系统中使用了 codeigniter,这是我的代码

$config['base_url'] = base_url()."/merchant/?";
    $config['total_rows'] = $count_result; // Count total rows in the query
    $config['full_tag_open'] = '<div class="pagination pagination-small pagination-centered"><ul>';
    $config['full_tag_close'] = '</ul></div>';
    $config['per_page'] = $limit;
    $config['num_links'] = 5;
    $config['page_query_string'] = TRUE;
    $config['prev_link'] = '&lt; Prev';
    $config['prev_tag_open'] = '<li>';
    $config['prev_tag_close'] = '</li>';
    $config['next_link'] = 'Next &gt;';
    $config['next_tag_open'] = '<li>';
    $config['next_tag_close'] = '</li>';
    $config['cur_tag_open'] = '<li class="active"><a href="#">';
    $config['cur_tag_close'] = '</a></li>';
    $config['num_tag_open'] = '<li>';
    $config['num_tag_close'] = '</li>';
    $config['first_link'] = FALSE;
    $config['last_link'] = FALSE;
    $this->pagination->initialize($config); 

    $this->data['links'] =  $this->pagination->create_links();

and I came up with this

我想出了这个

am i missing something here?

我在这里错过了什么吗?

enter image description here

在此处输入图片说明

回答by emanisof

Here is Mine, and It Works Using Bootstrap 3

这是我的,它使用 Bootstrap 3 工作

<?php if(!defined('BASEPATH')) exit('Direct Access Not Allowed');

/* This Application Must Be Used With BootStrap 3 *  */
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";

// end of file Pagination.php 
// Location config/pagination.php 
// By @emanisof 

回答by Mohammad Fakhruddin

1) Controlller       

        $this->load->library('pagination');
        $config = [
            'base_url' => base_url('admin/deactiveUser'),
            'per_page' => 10,
            'total_rows' => $this->AdminModel->num_rows(),
        ];

        $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['num_tag_open'] = '<li class="page-item">';
        $config['num_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['next_tag_open'] = '<li class="page-item">';
        $config['next_tagl_close'] = '</a></li>';
        $config['prev_tag_open'] = '<li class="page-item">';
        $config['prev_tagl_close'] = '</li>';
        $config['first_tag_open'] = '<li class="page-item disabled">';
        $config['first_tagl_close'] = '</li>';
        $config['last_tag_open'] = '<li class="page-item">';
        $config['last_tagl_close'] = '</a></li>';
        $config['attributes'] = array('class' => 'page-link');
        $this->pagination->initialize($config); // model function
        $seeker = $this->AdminModel->seekerlist($config['per_page'], $this->uri->segment(3)); // list of seeker

2)Model
public function seekerlist($limit,$offset) {
        $query = $this->db->select('*')
                ->from('user')
                ->limit($limit,$offset)
                ->get();

        return $query->result_array();
    }


    public function num_rows()
    {
        $query = $this->db->select('*')
                ->from('user')                
                ->get();

        return $query->num_rows();
    }



3)View

<tbody>
                                <?php foreach ($seeker as $seekerData): ?>


                                    <tr>
                                        <td class="checkbox-column">
                                            <img width="30" height="30" src="<?= base_url("uploads/{$seekerData['picpath']}"); ?>"/>
                                        </td>
                                        <td><?php echo ucfirst($seekerData['firstName']) . ' ' . ucfirst($seekerData['lastName']); ?></td>
                                        <td><?php echo $seekerData['currentJobTitle']; ?></td>
                                        <td><?php echo $seekerData['email']; ?></td>
                                        <td><?php echo $seekerData['mobileNum']; ?></td>
                                        <td><?php echo $seekerData['nationality']; ?></td>
                                        <td><span class="label label-danger">Deactive</span></td>
                                    </tr>


                                <?php endforeach; ?> 


                            </tbody>

                        </table>

                            <?= $this->pagination->create_links() ?>

回答by user1204987

Just change the below parameters :-

只需更改以下参数:-

$config['full_tag_open'] = '<div class="pagination pagination-small pagination-centered"><ul>';
$config['full_tag_close'] = '</ul></div>';

Replace it with :-

替换为:-

$config['full_tag_open'] = '<div><ul class="pagination pagination-small pagination-centered">';
$config['full_tag_close'] = '</ul></div>';

回答by jeromes

I find useful to redefine the standard label to have arrows instead:

我发现重新定义标准标签以使用箭头很有用:

$config['first_link'] = "<span aria-hidden=\"true\">&laquo;</span>";
$config['last_link'] = "<span aria-hidden=\"true\">&raquo;</span>";

It is also possible to customize prev_linkand next_link

也可以自定义prev_linknext_link

回答by Ashwani Garg

Your these tags were creating problem, Replace them like below

你的这些标签产生了问题,像下面那样替换它们

Replace this

替换这个

$config['full_tag_open'] = '<div class="pagination pagination-small pagination-centered"><ul>';
$config['full_tag_close'] = '</ul></div>';

With them

跟他们

$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] = '</ul>';