Welcome Guest, Not a member yet? Register   Sign In
Need help with counting articles on comments and categories on homepage
#1

[eluser]DumpProgrammer[/eluser]
I am trying to count the comments for the articles that are displayed on my home page. I do have a function alreday that displays the comments but it relies on the article id which on my home page has not yet been passed. I also need to get the article category so that a user can easily go to read similar stories. I am not sure what is going to be helpful but I will post my homepage controller and get comments controller.homepage
Code:
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');

    }
get article comments model
Code:
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;
}


Messages In This Thread
Need help with counting articles on comments and categories on homepage - by El Forum - 02-16-2010, 03:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB