php - CodeIgniter Load More Comment Result
anyone can help me to make load more or doing pagenation for the comment result of the topic content?. This is how it it works my topic content call the query using the slug now I want the topic content reply show by pagenation or via load more button
My topic content controller:
public function topic($slug = NULL) {
// get single topic
$data['item'] = $this->topic_model->getTopic($slug);
if(empty($data['item'])) {
$data['title'] = lang_key('404errorheader');
$data['desc'] = lang_key('404errordesc');
$this->load->view('themes/default/header', $data);
$this->load->view('errors/html/error_404');
$this->load->view('themes/default/footer');
}else{
$data['title'] = $data['item']['title'];
$data['desc'] = strip_tags(word_limiter($data['item']['content'],30));
$this->load->view('themes/default/header', $data);
$this->load->view('threads/topic', $data);
$this->load->view('themes/default/footer');
$this->add_view($slug);
}
}
and my topic content model:
// get single topic
public function getTopic($slug) {
$query = $this->db->get_where('threads', array('thread_slug'=>$slug));
return $query->row_array();
}
and my topic reply helper:
//get topic reply
if ( ! function_exists('get_topic_reply'))
{
function get_topic_reply($topic_id)
{
$CI = get_instance();
$CI->load->database();
$CI->db->order_by('id', 'asc');
$CI->db->where('topic_id',$topic_id);
$CI->db->where('status',1);
$query = $CI->db->get_where('threads_comment');
return $query;
}
}
This is how I display the result. mydomain/topic/topic-slug Content of the topic data is the topic content calling the query using slug and I only include the content reply via:
<?php require('topicreply.php');?>
The codes of this topicreply.php:
I want the result in topicreply.php will not display all instead there will be a load more button or pagenation. Anyone can help me? Ive been looking on the Internet but I cant find similar to my problem.
Note: The codes is working fine and no problem at all its only, I want the topic reply/comment can be view some of the reply via pagenation or loadmore!
Answer
Solution:
Its working now but instead of Load More I use pagination. Here the code in my controller
But I have another concern I hope someone can help me. The result numbering is my problem. As you can see the pagination will display 10 results every page but my result numbering once you go to second page instead the number will goes to 11 to 20 it will return to 1-10. Look the codes below