我在我的一个 codiegniter 页面中使用了分页,我想在 bootstrap 类中显示分页链接,这些链接在第一页上正确显示,但是当我单击 link2 时,链接没有正确显示。请告诉我我该如何调整它们。 这是我的查看页面。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<?php echo base_url()?>" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>User Handling</title>
<!-- Bootstrap -->
<link href="<?php echo base_url();?>css/bootstrap.min.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body class="container">
<div class="row">
<div class="col-lg-12">
<?php
if(isset($new_post))
{
foreach($new_post as $row)
{
echo '<h1>'.$row->tittle.'</h1>';
echo '<p style="background-color:#CCC;">'.$row->post.'</p>';
$row->id;
echo '<a href="index/post_edit/'.$row->id.'">Edit</a> ';
echo '<a href="index/delete_post/'.$row->id.'">Delete</a>';
echo '<br/>';
}
}
问题出在分页链接
if(isset($link)){
echo '<ul class="pagination"><li>'.$link.'</li></ul>';
echo '<br/>';
}
else{
echo'no link have been fired';
}
?>
<a href="<?php echo 'index';?>"><button class="btn btn-large btn-success">Home</button></a>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="<?php echo base_url();?>js/bootstrap.min.js"></script>
</body>
我传递这些链接的 Controller 函数。
function show_post()
{
$config['base_url'] = base_url().'index/show_post';
$config['total_rows'] = $this->user->record_count();
$config['per_page'] = 3;
$config['uri_segment']=3;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['link']=$this->pagination->create_links();
$data['new_post']=$this->user->getpost($config['per_page'],$page);
$this->load->view("post",$data);
}
分页正确的第一页。
分页不正确的第二页。
最佳答案
不是 codeigniter 分页类的专家,但我想您应该阅读标题为“自定义分页”和“添加封闭标记”的部分
http://ellislab.com/codeigniter/user-guide/libraries/pagination.html
如果您想更改链接的显示方式(链接周围的 html 等),我相信您需要使用提供的配置选项。
看看是否有帮助。
好的,编辑此内容为您添加一些代码...不过,这确实在文档中进行了解释。
// If you want to wrap your pagination in something
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
// If you want to wrap the "go to first" link
$config['first_link'] = 'First';
$config['first_tag_open'] = '<li class="whateverboostrap">';
$config['first_tag_close'] = '</li>';
// If you want to wrap the "go to last" link
$config['last_link'] = 'Last';
$config['last_tag_open'] = '<li class="whateverboostrap">';
$config['last_tag_close'] = '</li>';
// If you want to wrap the next link
$config['next_link'] = 'Next';
$config['next_tag_open'] = '<li class="whateverboostrap">';
$config['next_tag_close'] = '</li>';
// If you want to wrap the previous link
$config['prev_link'] = 'Last';
$config['prev_tag_open'] = '<li class="whateverboostrap">';
$config['prev_tag_close'] = '</li>';
// Wrap/style active link
$config['cur_tag_open'] = '<li class="active whateverboostrap">';
$config['cur_tag_close'] = '</li>';
// Wrap the 'digit' link.
$config['num_tag_open'] = '<li class="whateverboostrap">';
$config['num_tag_close'] = '</li>';
关于codeigniter - 使用 codiegniter 和 bootstrap 链接进行分页无法正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22252943/