29 lines
858 B
PHP
29 lines
858 B
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Category extends CI_Controller {
|
|
|
|
public function view($id = NULL) {
|
|
if ($id === NULL) {
|
|
redirect('home');
|
|
}
|
|
|
|
// 1. Charger les modèles nécessaires
|
|
$this->load->model('Game_model');
|
|
$this->load->model('Category_model');
|
|
|
|
// 2. Récupérer les infos de la catégorie pour afficher son nom
|
|
$this->db->where('categoryId', $id);
|
|
$data['category'] = $this->db->get('category')->row_array();
|
|
|
|
if (empty($data['category'])) {
|
|
show_404();
|
|
}
|
|
|
|
// 3. Récupérer tous les jeux de cette catégorie
|
|
$data['games'] = $this->Game_model->get_by_category($id);
|
|
|
|
// 4. Envoyer le tout à une nouvelle vue
|
|
$this->load->view('games_list_view', $data);
|
|
}
|
|
} |