Welcome Guest, Not a member yet? Register   Sign In
Trying to show a single blog post
#10

[eluser]cahva[/eluser]
How about if you change your code like this:

Controller:
Code:
function view($blog_id = FALSE) {
    if (!$blog_id)
    {
        return FALSE;
    }
    
    $data['post'] = $this->blogmodel->get_view($blog_id);
    
    if (!$data['post'])
    {
        // Maybe check the $data['post'] here and load a error view for non existing blogid
        $this->load->view('error');
        return FALSE;
    }
    
    $data['content'] = 'postview';

    $this->load->view('includes/template', $data);
}

and the model:
Code:
function get_view($blog_id){
    $this->db->where('blogId', $blog_id);
    $query = $this->db->get('blogposts');
    
    if ($query->num_rows() == 1) {
        return $query->row();
    }
    
    return FALSE;
}

As you see I removed using of $this->uri->segment(3). You can get the blogid just by adding it as a parameter to view method.


Messages In This Thread
Trying to show a single blog post - by El Forum - 05-20-2010, 06:53 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 06:56 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 07:26 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 09:53 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 10:00 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 10:01 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 10:01 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 11:23 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 11:32 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 11:49 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 11:58 AM
Trying to show a single blog post - by El Forum - 05-20-2010, 12:10 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 12:24 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 12:53 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 12:58 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 01:10 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 01:15 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 01:23 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 01:29 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 03:15 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 05:17 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 05:33 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 05:46 PM
Trying to show a single blog post - by El Forum - 05-20-2010, 05:57 PM
Trying to show a single blog post - by El Forum - 05-21-2010, 12:51 AM
Trying to show a single blog post - by El Forum - 05-21-2010, 01:34 AM
Trying to show a single blog post - by El Forum - 05-21-2010, 07:44 AM
Trying to show a single blog post - by El Forum - 05-22-2010, 06:02 AM
Trying to show a single blog post - by El Forum - 05-24-2010, 09:04 AM
Trying to show a single blog post - by El Forum - 05-24-2010, 10:10 AM
Trying to show a single blog post - by El Forum - 05-24-2010, 12:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB