我正在嘗試將一篇長篇文章分頁,以便在基於codeigniter框架構建的網站的移動設備上查看。 我已經能夠確定文章的頁數,但是在創建鏈接和能夠將參數傳遞給uri進行分頁時丟失了。 這是我的代碼從我的控制器分頁的長文章
function view_post($alias)
{
$post = $this->post_model->load_post($alias);
$data['title'] = $post->post_title;
$data['logged'] = $this->ion_auth->logged;
$data['user_id'] = $this->ion_auth->user;
$data['username'] = $this->ion_auth->username;
$data['comments'] = $this->comment_model->count_post_comments($post->ID);
$link = strtolower($post->name)."/".$post->alias;
$data['post_link'] = "www.giggsmagazine.com/".$link;
$data['post'] = $post;
// Article Pagination for long articles
$posts = explode("<!-- pagebreak -->",$post->post_content);
$page_count = count($posts) - 1;
$data['pages'] = $page_count;
$data['posts'] = $posts;
if($this->isMobile())
{
$device = $this->agent->mobile;
switch($device)
{
case "BlackBerry":
$this->load->view('mobile/bb/inc/bb_header',$data);
$this->load->view('mobile/bb/posts/view_post');
$this->load->view('mobile/bb/inc/bb_footer');
break;
case "Apple Iphone" || "Apple Ipod Touch":
$this->load->view('mobile/iphone/inc/iphone_header',$data);
$this->load->view('mobile/iphone/posts/view_post');
$this->load->view('mobile/iphone/inc/iphone_footer');
break;
default:
$this->load->view('mobile/generic/inc/generic_header',$data);
$this->load->view('mobile/generic/view_post');
$this->load->view('mobile/generic/inc/generic_footer');
break;
}
}else {
$this->load->view('templates/site_header',$data);
$this->load->view('posts/view_post');
$this->load->view('templates/site_footer');
}
}
請點我在正確的方向
am分頁長文章不是數據庫記錄 – MrFoh
CI的分頁庫不需要一套數據庫記錄工作 - 但嘿,無論漂浮你的船:) – Mudshark