0
0

Добрый вевечер!

Мне нужна помощь курс codeigniter 3 урок 2-4 не открываются сыллки для перехода новостей.

При клике на новость 1 или новость 2 выдаёт ошибку 404.https://drive.google.com/file/d/16nh43-yzJEnoWqC1B8AX2WRUKR4ofI8W/view?usp=sharing

С Уважением 
Никита

<h1>Все новости</h1>

<?php foreach ($news as $key => $value): ?>
<p> <a href="view/<?php echo $value['slug']; ?>"><?php echo $value['title']; ?></a></p>
<?php endforeach ?>

<?php 

defined('BASEPATH') OR exit('No direc script access allowed');

class News extends CI_Controller {

	public function __construct() {
		parent::__construct();
		$this->load->model('news_model');
	}

	public function index() {
		$data['title'] = "Все новости";
		$data['news'] = $this->news_model->getNews();

		$this->load->view('templates/header', $data);
		$this->load->view('news/index', $data);
		$this->load->view('templates/footer');

	}

	public function view($slug = NULL) {
		$data['news_item'] = $this->news_model->getNews($slug);

		if(empty($data['news_item'])) {
			show_404();
		}

		$data['title'] = $data['news_item']['title'];
		$data['content'] = $data['news_item']['text'];

		$this->load->view('templates/header', $data);
		$this->load->view('news/view', $data);
		$this->load->view('templates/footer');
	}

}





<?php 

class News_model extends CI_Model {

	public function __construct() {
		$this->load->database();
	}

	public function getNews($slug = FALSE) {
		if($slug === FALSE) {
			$query = $this->db->get('news');
			return $query->result_array();
		}

		$query = $this->db->get_where('news', array('slug' => $slug));
		return $query->row_array();
	}




}

 


Никита Сёмин
2 weeks ago






Еще нет ответов