[eluser]Unknown[/eluser]
hi.
i have a little issue with something i am building.
it is a simple news system (add, del, edit) for multiple websites.
i have a controller called news.php
Code:
<?php
class news extends CI_Controller
{
function index()
{
redirect('/', 'location');
}
function add()
{
$options = array(
'headline' => $this->input->post('headline'),
'text' => $this->input->post('text'),
'author' => $this->input->cookie('username'),
);
$data['current_view'] = 'news_view';
$this->form_validation->set_rules('headline', 'Headline', 'required');
$this->form_validation->set_rules('text', 'Text', 'required');
if($this->form_validation->run() == TRUE)
{
$this->load->model('news_model');
$data['news'] = $this->news_model->add($options, $this->uri->segment(2));
}
$this->load->view('includes/template', $data);
}
function del()
{
$options = array(
'sortBy' => 'id',
'sortDescription' => 'desc'
);
$data['current_view'] = 'news_view';
$this->load->model('news_model');
$data['news'] = $this->news_model->del($options, $this->uri->segment(3));
$this->load->view('includes/template', $data);
}
}
?>
it is not finish yet.
the hyperlinks i need to have is.
1) /news/<website>/add
2) /news/<website>
under 1) i will have a form with form_open etc.
to add a news to the website there is defined in segment 2.
under 2) will i have a list view of all the news for the website defined in segment 2, in that list i will have 2 links (edit & del) the links for that i think should be /news/<website>/del/<id> and /news/<website>/edit/<id>
but with that controller i posted i do get a 404 when i go to add news (/news/<website>/add).
i can't use
Code:
if($this->uri->segment(3) == 'add'):
in the view to control if the segment is that.
if you need more code, ex my view you can get that.
Kind regards
Simon