08-22-2012, 03:18 AM
[eluser]Peter Englmaier[/eluser]
As a Newbee I did the news-tutorial of course and went straight into the 404-error (August, 21, 2012). The issue with $news_item and $news was the problem. Thank you, "lesharris".
Here in detail for the beginners what has to be changed in the code:
In ".../views/news/view.php": change $news_item to $news (two variables)
In ".../views/news/index.php: change $news_item to $news (four variables)
In ".../controller/news.php":
change old part of code:
to the NEW part of code:
Then it works!
Don't forget to reload the pages (the cache!) ... as I did forget ;-)
As a Newbee I did the news-tutorial of course and went straight into the 404-error (August, 21, 2012). The issue with $news_item and $news was the problem. Thank you, "lesharris".
Here in detail for the beginners what has to be changed in the code:
In ".../views/news/view.php": change $news_item to $news (two variables)
In ".../views/news/index.php: change $news_item to $news (four variables)
In ".../controller/news.php":
change old part of code:
Code:
public function view($slug)
{
$data['news_item'] = $this->news_model->get_news($slug);
if (empty($data['news_item']))
{
show_404();
}
$data['title'] = $data['news_item']['title'];
$this->load->view('templates/header', $data);
$this->load->view('news/view', $data);
$this->load->view('templates/footer');
}
to the NEW part of code:
Code:
public function view($slug)
{
$data['news'] = $this->news_model->get_news($slug);
if (empty($data['news']))
{
show_404();
}
$data['title'] = $data['news']['title'];
$this->load->view('templates/header', $data);
$this->load->view('news/view', $data);
$this->load->view('templates/footer');
}
Then it works!
Don't forget to reload the pages (the cache!) ... as I did forget ;-)