skip to Main Content

The activate page is always bolded and somehow out of place. Not sure where I’m going wrong. I’m just trying to display the page links as individual links, planning to add CSS on later but can’t seem to find out how to get rid of the active page link. Also, I’m using Twitter Bootstrap 3.

Controller:

private function paginate_create_table($search = null)
{
    // Set pagination configuration
    $config = array();
    $config['base_url'] = base_url()."index.php/Home/on_hold_lot";
    $config['suffix'] = '?cust_drop_down='.$search['customer'].'&area_drop_down='.$search['stage'].'&status_drop_down='.$search['lot_status'].'&search_lot='.$search['search_lot'];
    $config['first_url'] = $config['base_url'].$config['suffix'];
    $config['total_rows'] = $this->home_model->fetch_lots('rows', $search);
    $config['per_page'] = 10;
    $config['uri_segment'] = 3;
    $config['next_link'] = 'Next';
    $config['prev_link'] = 'Previous';

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

    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
    $results = $this->home_model->fetch_lots('array', $search, $config['per_page'], $page);

    return $results;
}

public function load_lot_table()
{
    // Get form values
    if($this->input->get())
    {
        $search = array(
        'customer' => $this->input->get('cust_drop_down'),
        'stage' => $this->input->get('area_drop_down'),
        'lot_status' => $this->input->get('status_drop_down'),
        'search_lot' => $this->input->get('search_lot')
        );
    }
    else
    {
        $search = array(
        'customer' => 'all',
        'stage' => 'all',
        'lot_status' => 'all',
        'search_lot' => ''
        );
    }

    // Paginate retrieved lots
    $results = $this->paginate_create_table($search);

    if($results != FALSE)
    {
        // Assign retrieved lots to assoc array
        $data['disp_rows'] = $results;

        // Create page links for Next page, Page 1 etc
        $str_links = $this->pagination->create_links();
        $data['links'] = explode(" ", $str_links);
    }
    else
    {
        $data['error_message'] = "No rows";
    }

    return $this->load->view('home/lot_disposition', $data);
}

View:

<div class="container text-right">
    <ul class="pagination">
        <?php foreach ($links as $link)
            {
                echo "<li>$link</li>";
            }
        ?>
    </ul>
</div>

enter image description here

2

Answers


  1. You can change the config for your pagination like this,

        $config['last_link'] = 'Last';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
        $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['first_link'] = 'First';
        $config['first_tag_open'] = '<li>';
        $config['first_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['prev_link'] = '&laquo;';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&raquo;';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
    

    and in view, you can just echo $links

     <div class="container text-right">
           <?= $links ?>
     </div>
    

    Rest everything will remain same, only config and echo in view

    Login or Signup to reply.
  2. Remove this code in your code(above in controller)

    $config['next_link'] = 'Next';
    $config['prev_link'] = 'Previous';
    

    and add Bootstrap code for it.

    // style
    $config['full_tag_open'] = '<ul class="pagination">';
    $config['full_tag_close'] = '</ul>';
    $config['first_link'] = false;
    $config['last_link'] = false;
    $config['first_tag_open'] = '<li>';
    $config['first_tag_close'] = '</li>';
    $config['prev_link'] = '&laquo';
    $config['prev_tag_open'] = '<li class="prev">';
    $config['prev_tag_close'] = '</li>';
    $config['next_link'] = '&raquo';
    $config['next_tag_open'] = '<li>';
    $config['next_tag_close'] = '</li>';
    $config['last_tag_open'] = '<li>';
    $config['last_tag_close'] = '</li>';
    $config['cur_tag_open'] = '<li class="active"><a href="#">';//this is active tab
    $config['cur_tag_close'] = '</a></li>';
    $config['num_tag_open'] = '<li>';
    $config['num_tag_close'] = '</li>';
    

    On the active tab can use Bold(<b>) or any other styles

    an this code is working without any error. Tested

    My output(Without Bold Style)

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search