• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a bit of logic help wanted

#1
[eluser]DumpProgrammer[/eluser]
I have a variable in my controller that I call three times on my home page but I would like it to have different articles showing up on my page rather than have the same items three times. Here is the code
Code:
$data['post'] = $this->MPosts->getAllActivePosts();
. So have been retrieving the active post on website with some with pictures and some just the headings. What I would like to have is a start and limit so that there is a continuation of the mysql query on the three articles on the page because its news so I cannot have the same four topics showing. So do I have to perform the same query with different parameters or do I have to use a different variable for my articles?

#2
[eluser]markup2go[/eluser]
You want to look in your model and update the query in getAllActivePosts(). Post this function if you need help with that.

#3
[eluser]DumpProgrammer[/eluser]
here is the controller
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');

    }
and here is the model
Code:
function getAllActivePosts(){
     $data = array();
     $this->db->limit(4);
     $this->db->where('status', 'published');
     $Q = $this->db->get('posts');
     if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
         $data[] = $row;
       }
    }
    $Q->free_result();  
    return $data;
}
I hope that helps.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.