Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to style pagination links without config - codeigniter

I have the following pagination style

                            <ul class="pagination">
                            <li><a href="#"><i class="fa fa-long-arrow-left"></i>Previous Page</a></li>
                            <li class="active"><a href="#">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#">4</a></li>
                            <li><a href="#">Next Page<i class="fa fa-long-arrow-right"></i></a></li>
                            </ul><!--/.pagination--> 

i want to make the above static code dynamic without using config

<ul class="pagination">

<?php echo $this->pagination->create_links(); ?>

</ul><!--/.pagination--> 

Controller

        $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>";
        $this->pagination->initialize($config); 
like image 287
Chaitanya K Avatar asked Dec 05 '22 03:12

Chaitanya K


2 Answers

Ok i have tried, This Controller code works fine

    $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="active"><a href="#">';
    $config['cur_tag_close'] = '</a></li>';
    $config['prev_tag_open'] = '<li>';
    $config['prev_tag_close'] = '</li>';
    $config['first_tag_open'] = '<li>';
    $config['first_tag_close'] = '</li>';
    $config['last_tag_open'] = '<li>';
    $config['last_tag_close'] = '</li>';



    $config['prev_link'] = '<i class="fa fa-long-arrow-left"></i>Previous Page';
    $config['prev_tag_open'] = '<li>';
    $config['prev_tag_close'] = '</li>';


    $config['next_link'] = 'Next Page<i class="fa fa-long-arrow-right"></i>';
    $config['next_tag_open'] = '<li>';
    $config['next_tag_close'] = '</li>';


    $this->pagination->initialize($config); 

View

 <?php echo $this->pagination->create_links(); ?>
like image 75
Chaitanya K Avatar answered Jan 04 '23 09:01

Chaitanya K


In your controller add this config.

               $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="active"><a href="#">';
                $config['cur_tag_close'] = '</a></li>';
                $config['prev_tag_open'] = '<li>';
                $config['prev_tag_close'] = '</li>';
                $config['first_tag_open'] = '<li>';
                $config['first_tag_close'] = '</li>';
                $config['last_tag_open'] = '<li>';
                $config['last_tag_close'] = '</li>';

                $config['next_link'] = 'Next Page';
                $config['next_tag_open'] = '<li><i class="fa fa-long-arrow-right"></i>';
                $config['next_tag_close'] = '</li>';

                $config['prev_link'] = 'Previous Page';
                $config['prev_tag_open'] = '<li><i class="fa fa-long-arrow-left"></i>';
                $config['prev_tag_close'] = '</li>';
                $this->pagination->initialize($config); 

and in your view just only echo pagination

<?php echo $this->pagination->create_links(); ?>

remove the ul

like image 36
Kamran Avatar answered Jan 04 '23 10:01

Kamran