我的网站分页位于“user_area”控制器文件中的“home”功能内。 我按照此页Pagination
中的示例进行操作除了混淆我的base_url之外,分页工作正常。当我单击分页链接,然后单击网站导航栏中的链接时,“主页”将添加到所有链接。
欢迎任何帮助。
控制器:
public function home(){
if($this->session->userdata('is_logged_in')){
$this->load->model('model_match');
$this->load->model('model_user');
$this->load->model('model_msg');
$pagination = array();
$pagination["total_rows"] = $this->model_match->countMatches();
$pagination["per_page"] = 2;
$pagination["uri_segment"] = 3;
$choice = $pagination["total_rows"] / $pagination["per_page"];
$pagination["num_links"] = round($choice);
$pagination['base_url'] = base_url('user_area/home');
$this->pagination->initialize($pagination);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["videos"] = $this->model_match->getAllMatches($pagination["per_page"], $page);
$data["links"] = $this->pagination->create_links();
$data['count_unread_msgs'] = $this->model_msg->countUnreadMsgs($this->session->userdata('user'));
$data['count_unread_hearts'] = $this->model_msg->countUnreadHearts($this->session->userdata('user'));
$data['user_name'] = $this->session->userdata('user');
//$data['videos'] = $this->model_match->getAllMatches();
$this->load->view('user/matches',$data);
}else{
redirect('home');
}
}
导航栏:
<nav>
<a href="home">Home</a>
<a href="message_center">Messages</a>
<a href="account">Account</a>
<a href="library">Portfolio</a>
<a href="favorites">Favorites</a>
<a href="viewer-help.php">Help / FAQ </a> -->
<a href="toolkit">Toolkit</a>
<a href="<?php echo base_url()."login/logout";?>">Logout</a>
<?php searchOptions();?>
</nav>
答案 0 :(得分:0)
你的问题
<a href="toolkit">Toolkit</a>
是相对路径链接,
你应该在所有导航链接上做这样的事情作为最佳实践:
<a href="<?php echo base_url('toolkit');?>">Toolkit</a>
或
<a href="<?=base_url('toolkit');?>">Toolkit</a>
如果您的服务器支持短打开标签