public function index($id = '') { $categories_all = Categories::find(); if ($id) { $categories = array(Categories::findByPk($id)); } else { $categories = Categories::find(); } $this->render('Articles/list', array('categories_all' => $categories_all, 'categories' => $categories)); }
if ($category->primaryKey == @$_GET["category_id"]) { echo 'selected="selected"'; } ?> ><?php echo $category->category; ?> </option><?php } ?> </select> </form> <table><?php if (@$_GET["category_id"] != 0) { $categories = array(Categories::findByPk($_GET["category_id"])); } else { $categories = Categories::find(); } foreach ($categories as $category) { ?> <tr><td colspan="4"><h2><?php echo $category->category; ?> </h2></td></tr> <tr> <th>Image</th> <th>Titre</th> <th>Prix</th> <th>Panier</th> </tr><?php
if ($category->primaryKey == @$_GET["category_id"]) { echo 'selected="selected"'; } ?> ><?php echo $category->category; ?> </option><?php } ?> </select> </form> <table><?php //Si une categorie est selectionnée, on n'affiche que celle-ci, sinon on affiche tout if (@$_GET["category_id"] && $_GET["category_id"] != 0) { $catSelected = \Models\Categories::findByPk($_GET["category_id"]); ?> <tr> <td colspan="4"><h2><?php echo $catSelected->category; ?> </h2></td> </tr> <tr> <th>Image</th> <th>Titre</th> <th>Prix</th> <th>Panier</th> </tr><?php //Selection des articles d'une categorie $catArticles = $catSelected->articles;