The CI forum is being annoying, and won't load for me, and I know some of you use this framework, I started learning it yesterday, and don't quite understand how URL's work, even after reading the userguide.
I have http://localhost:8888/cms/site/posts/
site being the controller, posts being the method/function within. I want to have a URL structure such as
http://localhost:8888/cms/site/posts/edit/2
I tried adding the edit function WITHIN the posts function, however it doesn't work and simply just runs the post function as normal. I was wondering if anyone could help?
Site Controller:
I have http://localhost:8888/cms/site/posts/
site being the controller, posts being the method/function within. I want to have a URL structure such as
http://localhost:8888/cms/site/posts/edit/2
I tried adding the edit function WITHIN the posts function, however it doesn't work and simply just runs the post function as normal. I was wondering if anyone could help?
Site Controller:
Code:
<?php
class Site extends CI_Controller{
function __construct(){
parent::__construct();
// See if session set
$this->is_logged_in();
}
function index(){
// Show members area
$data['main_content'] = 'members/members_area';
$this->load->view('includes/template',$data);
}
function posts(){
$this->load->model('posts_model');
$this->load->library('table');
$this->table->set_heading(array('Title', 'Author','Category'));
$data['posts'] = $this->posts_model->get_posts();
// Show members area
$data['main_content'] = 'members/posts';
$this->load->view('includes/template',$data);
// I put this WITHIN the posts function to try and get the URL structure correct
function edit(){
$this->load->model('posts_model');
$data['post'] = $this->posts_model->get_a_post($this->uri->segment(4));
$data['main_content'] = 'members/posts_edi1t';
$this->load->view('includes/template',$data);
}
}
function is_logged_in(){
$is_logged_in = $this->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in != true){
echo 'You don\'t have access';
die();
}
}
}