Answer the question
In order to leave comments, you need to log in
Why doesn't Codeignater 3 post page display work?
Good day. I'm doing a test task, but there was a problem that I can not overcome. When passing by reference to the model through the controller, the slug record is not transferred.
Here is the controller file:
public function show($slug = NULL) {
$data['news_item'] = $this->news_model->getSingleNews($slug);
if(empty($data['news_item'])) {
show_404();
}
$data['slug'] = $slug;
$this->load->view('blocks/header', $data);
$this->load->view('news/show', $data);
$this->load->view('blocks/footer');
}
public function getSingleNews($slug) {
$query = $this->db->get_where('news', array('slug' => $slug));
return $query->row_array();
}
$route['news/article/(:any)'] = 'news/show/$1';
<a href="/news/article/<?php echo $news_item['slug']; ?>">More...</a>
. I will be grateful for any help.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question