misheck Posted February 16, 2010 Share Posted February 16, 2010 I am stuck on completing my first CI website. I need to get the comment counts and article category on my homepage. I have functions already in my models that retrieves this information but they all need an id passed in the function in order to retrieve the correct information for the articles. So I can retrieve both the comment count and category in my article view but I cannot on the homepage because the homepage contains multiple articles from various categories. I dont what addittional information I can post here but I will post my homepage controller and the getcomments model . Homepage function index() { $data['cats'] = $this->MCats->getTopCategories(); //we will replace soon! $data['title'] = "Shout-Africa"; $data['main'] = 'public_home'; $data['featured'] = $this->MPosts->getAllFeaturedPosts(); $data['post'] = $this->MPosts->getAllActivePosts(); $data['comms'] = $this->MComments->getLatestComments(); $this->load->vars($data); $this->load->view('newheader'); $this->load->view('newnav'); $this->load->view('newfeatured'); $this->load->view('newcontent'); $this->load->view('newvideo'); $this->load->view('newrightside'); $this->load->view('newwidget'); $this->load->view('footer'); } the getcomments model function getComments($postid){ $data = array(); $this->db->where('post_id',$postid); $Q = $this->db->get('comments'); if ($Q->num_rows() > 0){ foreach ($Q->result_array() as $row){ $data[] = $row; } } $Q->free_result(); return $data; } Any help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/192240-help-with-getting-comments-count-and-article-category-in-codeigniter/ Share on other sites More sharing options...
mapleleaf Posted March 4, 2010 Share Posted March 4, 2010 I think you want the total comments per category. Anyway it seems you just need a function in the modal for the query you want as you can't use the function that requires an id. By the way the codeigniter forum is exellent. Quote Link to comment https://forums.phpfreaks.com/topic/192240-help-with-getting-comments-count-and-article-category-in-codeigniter/#findComment-1021231 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.