如何在Codeigniter中隐藏分页类中的页面链接?

I am trying to achieve the following effect:

Prev 1 of 4 Next

I have tried setting the following $config option:

$config['num_links'] = 0;

But I get the following error:

Your number of links must be a positive number.

My config options are set as:

    $config['base_url'] = "/browse/tag/$tid/";
    $config['total_rows'] = $num_items;
    $config['per_page'] = $max_items;
    $config['first_link'] = FALSE;
    $config['last_link'] = FALSE;
    $config['uri_segment'] = 4;
    $config['use_page_numbers'] = TRUE;
    $config['display_pages'] = TRUE;
    $config['num_links'] = 0; # this doesn't work
    $config['prev_link'] = 'Previous';
    $config['next_link'] = 'Next';
    $config['cur_tag_open'] = '<span>';
    $config['cur_tag_close'] = " of $pages</span>";
    $config['full_tag_open'] = '<div class="previousnext">';
    $config['full_tag_close'] = '</div>';

If I change num_links to 1, I obviously get:

Prev 1 2 of 4 3 Next

And if I turn off display_pages I get:

Prev Next

At this stage, I would like to avoid modding core code.

If it's fine for you to have the digit links to exitst in HTML but not be displayed you may want to simply hide them using CSS.

Use $config['num_tag_open'] to define an open tag with class, e.g.:

$config['num_tag_open'] = '<div class="hidden">';

And then simply add a CSS:

.hidden { display: none; }

You need to extend the Pagination Class by creating a MY_Pagination.php file in the application/libraries directory and use it to override the create_links() function, which is responsible for echoing out the list of pages.

MY_Pagination.php

class MY_Pagination extends CI_Pagination{
    public function __construct(){
        parent::__construct();
    }

    public function create_links(){
        //copy and paste the logic from system/libraries/Pagination.php
        //but reimplement lines ~258-296 (CI 2.1.3) 
    }
}

By making the changes in your application directory and extending the core, you're safeguarding yourself against future core upgrades (from 2.1.3 to 3.0 for example).