Пример #1
0
 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));
 }
Пример #2
0
    }
    ?>
><?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 
    $articles = $category->articles;
    foreach ($articles as $article) {
Пример #3
0
<div id="list">

    <form action="<?php 
echo htmlentities($_SERVER["REQUEST_URI"]);
?>
" method="get">
        <select name="category_id" onchange="this.form.submit();">
            <option value="0">--- Tout ---</option><?php 
//Selection des categories
$allCategories = \Models\Categories::find();
foreach ($allCategories as $category) {
    ?>
                <option value="<?php 
    echo $category->primaryKey;
    ?>
"<?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) {