CodeIgniter中的Boostrap 4 Beta分页

时间:2017-09-18 20:32:11

标签: codeigniter

我正在使用CodeIniter和Boostrap 4 Beta制作网络应用。我坚持在CodeIgniter分页$ config

上集成boostrap 4样式

如何正确整合它?

1 个答案:

答案 0 :(得分:2)

CodeIgniter使输出HTML非常容易匹配bootstrap 4样式:

$this->load->library('pagination');

// This is how you match BASIC bootstrap 4 styles for pagination
$pagination_config = array(
    'first_tag_open'  => '<li class="page-item">',
    'first_tag_close' => '</li>',
    'last_tag_open'   => '<li class="page-item">',
    'last_tag_close'  => '</li>',
    'next_tag_open'   => '<li class="page-item">',
    'next_tag_close'  => '</li>',
    'prev_tag_open'   => '<li class="page-item">',
    'prev_tag_close'  => '</li>',
    'cur_tag_open'    => '<li class="page-item active">',
    'cur_tag_close'   => '</li>',
    'num_tag_open'    => '<li class="page-item">',
    'num_tag_close'   => '</li>'    
);

// Example of how to add any other pagination configuration ...
$pagination_config['base_url'] = 'http://example.com/index.php/test/page/';
$pagination_config['total_rows'] = 200;
$pagination_config['per_page'] = 20;

// Initialize the pagination
$this->pagination->initialize($pagination_config);

在视图中输出分页时,您将使用以下内容:

<nav aria-label="Page navigation example">
    <ul class="pagination">
        <?php echo $this->pagination->create_links(); ?>
    </ul>
</nav>

如果您阅读CodeIgniter用户指南,那么您的成功将非常有益。