如何在Codeigniter中的分页中为每个锚标签添加li标签

时间:2014-11-04 14:44:11

标签: php codeigniter twitter-bootstrap-3

我使用以下配置进行分页

  $config['base_url'] = base_url() . 'index.php/admin/list_employees';
  $config['total_rows'] =   $this->database->get_num_records('user');
  $config['per_page'] = 10; 
  $config['uri_segment'] = 3;
  $config['num_links'] = 9;       

  $config['full_tag_open'] = '<div class="text-center"><ul class="pagination">';
  $config['full_tag_close'] = '</ul></div><!--pagination-->';

它呈现为

div class="text-center"><ul="pagination">&nbsp;<strong>1</strong>&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/10">2</a>
&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/20">3</a>
&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/30">4</a>
&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/40">5</a>
&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/50">6</a>
&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/60">7</a>
&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/70">8</a>
&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/80">9</a>
&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/90">10</a>
&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/10">&gt;</a>
&nbsp;&nbsp;<a href="http://localhost/PhpProject2/index.php/admin/list_employees/110">Last &rsaquo;</a>
</ul></div><!--pagination-->

如何将<li>添加到每个锚标记

2 个答案:

答案 0 :(得分:3)

添加以下配置:

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

答案 1 :(得分:0)

为了根据需要将所有链接包装在分页内,您需要指定很多配置。如下:

$cfg['full_tag_open']= '<div class="cols-xs-12 text-center"><ul   class="pagination">';
$cfg['full_tag_close']= '</ul></div>';
// first link
$cfg['first_tag_open']= '<li class="first">';
$cfg['first_tag_close']= '</li>';
// last link
$cfg['last_tag_open']= '<li class="last">';
$cfg['last_tag_close']= '</li>';
// current active pagination
$cfg['cur_tag_open'] = '<li class="active"><a href="#">';
$cfg['cur_tag_close'] = '</a></li>';
// number link
$cfg['num_tag_open'] = '<li>';
$cfg['num_tag_close'] = '</li>';
// next (>) link
$cfg['next_tag_open'] = '<li>';
$cfg['next_tag_close'] = '</li>';
// prev (<) link
$cfg['prev_tag_open'] = '<li>';
$cfg['prev_tag_close'] = '</li>';