非法字符串偏移错误

时间:2017-01-17 20:17:24

标签: php codeigniter pagination hmvc

我正在使用hmvc codeigniter。我已经制作了一个分页模块,最后一个函数指定了分页配置但是我得到了错误,比如这个

消息:非法字符串偏移'per_page'

消息:未初始化的字符串偏移量:0

每次我尝试在generate_pagination函数中分配变量时都会发生这种情况。非常感谢帮助。

    <?php
class Custom_pagination extends MX_Controller
{

function __construct() 
{
    parent::__construct(); // constructs from the mx controller
    $this->load->library('pagination');
}

function _generate_pagination($template)
{


if($template=="public_bootstrap")
{
    $settings = $this->get_settings_for_public_bootstrap();
}



$config['base_url'] = 'http://example.com/index.php/test/page/';
$config['total_rows'] = 200;
$config['per_page'] = $settings['per_page'];; 

$config['num_links'] = $settings['num_links'];

$config['full_tag_open'] = $settings['full_tag_open'];
$config['full_tag_close'] = $settings['full_tag_close'];

$config['cur_tag_open'] = $settings['cur_tag_open'];
$config['cur_tag_close'] = $settings['cur_tag_close'];

$config['num_tag_open'] = $settings['num_tag_open'];
$config['num_tag_close'] = $settings['num_tag_close'];

$config['first_link'] = $settings['first_link'];
$config['first_tag_open'] = $settings['first_tag_open'];
$config['first_tag_close'] = $settings['first_tag_close'] ;

$config['last_link'] = $settings['last_link'];
$config['last_tag_open'] = $settings['last_tag_open'];
$config['last_tag_close'] = $settings['last_tag_close'];

$config['prev_link'] = $settings['prev_link'];
$config['prev_tag_open'] = $settings['prev_tag_open'];
$config['prev_tag_close'] = $settings['prev_tag_close'];

$config['next_link'] = $settings['next_link'];
$config['next_tag_open'] = $settings['next_tag_open'];
$config['nex_tag_close'] = $settings['nex_tag_close'];          

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

$pagination = $this->pagination->create_links();
return $pagination;

}

function get_settings_for_public_bootstrap()
{



    $settings['per_page'] = 20; 

    $settings['num_links'] = 12;

    $settings['full_tag_open'] = '<nav aria-label="Page navigation"><ul class="pagination">';
    $settings['full_tag_close'] = '</ul></nav>';

    $settings['cur_tag_open'] = '<li class=disabled"><a href="#">';
    $settings['cur_tag_close'] = '</a></li>';

    $settings['num_tag_open'] = '<li>';
    $settings['num_tag_close'] = '</li>';

    $settings['first_link'] = 'First';
    $settings['first_tag_open'] = '<li>';
    $settings['first_tag_close'] = '</li>';

    $settings['last_link'] = 'Last';
    $settings['last_tag_open'] = '<li>';
    $settings['last_tag_close'] = '</li>';

    $settings['prev_link'] = '<span aria-hidden="true">&laquo;</span>';
    $settings['prev_tag_open'] = '<li>';
    $settings['prev_tag_close'] = '</li>';

    $settings['next_link'] = 'span aria-hidden="true">&laquo;</span>';
    $settings['next_tag_open'] = '<li>';
    $settings['nex_tag_close'] = '</li>';                   

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

    $pagination = $this->pagination->create_links();
    return $pagination;
}
}

0 个答案:

没有答案