Skip to content

Commit

Permalink
fix btns
Browse files Browse the repository at this point in the history
  • Loading branch information
szonchello-fi committed Jun 21, 2020
1 parent 8040264 commit 240b90a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 5 additions & 5 deletions controllers/Controller_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ public function action_orderBy() {
$defaultCategorie = -1;
$categories = $categoriesManager->getAllCategories();

if(!empty($_POST) || !empty($_GET)){
if(!empty($_GET)){

if (isset($_GET["tri"])) {
$typeAffichage = $_GET["tri"];
} else {
$typeAffichage = $_POST['ordreSelect'] ?? false;
$typeAffichage = $_GET['ordreSelect'] ?? false;
}

$category = $_POST['idCategory'] ?? false;
$category = $_GET['idCategory'] ?? false;

$min = $_POST['min'] ?? false;
$max = $_POST['max'] ?? false;
$min = $_GET['min'] ?? false;
$max = $_GET['max'] ?? false;

if(is_numeric($category)){
$category = intval($category);
Expand Down
4 changes: 2 additions & 2 deletions models/class.ArticlesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public function getAllArticles(string $typeAffichage, bool $afficherQuantitePosi
$end = min(($offset + $limit), $total);
}

$this->prevlink = ($this->page > 1) ? '<a class="page-link" href="?controller=index&action=orderBy&tri='.$typeAffichage.'&page=1" title="First page">&laquo;</a></li> <li class="page-item"><a class="page-link" href="?controller=index&action=orderBy&tri='.$typeAffichage.'&page=' . ($this->page - 1) . '" title="Previous page">&lsaquo;</a>' : '<a class="page-link" href="#" aria-label="Previous"><span class="disabled">&laquo;</span></a></li> <li class="page-item"><a class="page-link" href="#" aria-label="First Page"><span class="disabled">&lsaquo;</span></a>';
$this->nextlink = ($this->page < $this->pages) ? '<a class="page-link" href="?controller=index&action=orderBy&tri='.$typeAffichage.'&page=' . ($this->page + 1) . '" title="Next page">&rsaquo;</a></li> <li class="page-item"><a class="page-link" href="?controller=index&action=orderBy&tri='.$typeAffichage.'&page=' . $this->pages . '" title="Last page">&raquo;</a>' : '<a class="page-link" href="#" aria-label="Next"><span class="disabled">&rsaquo;</span></a></li> <li class="page-item"><a class="page-link" href="#" aria-label="Last Page"><span class="disabled">&raquo;</span></a>';
$this->prevlink = ($this->page > 1) ? '<a class="page-link" href="?controller=index&action=orderBy&idCategory='.$categorie.'&tri='.$typeAffichage.'&page=1" title="First page">&laquo;</a></li> <li class="page-item"><a class="page-link" href="?controller=index&action=orderBy&idCategory='.$categorie.'&tri='.$typeAffichage.'&page=' . ($this->page - 1) . '" title="Previous page">&lsaquo;</a>' : '<a class="page-link" href="#" aria-label="Previous"><span class="disabled">&laquo;</span></a></li> <li class="page-item"><a class="page-link" href="#" aria-label="First Page"><span class="disabled">&lsaquo;</span></a>';
$this->nextlink = ($this->page < $this->pages) ? '<a class="page-link" href="?controller=index&action=orderBy&idCategory='.$categorie.'&tri='.$typeAffichage.'&page=' . ($this->page + 1) . '" title="Next page">&rsaquo;</a></li> <li class="page-item"><a class="page-link" href="?controller=index&action=orderBy&idCategory='.$categorie.'&tri='.$typeAffichage.'&page=' . $this->pages . '" title="Last page">&raquo;</a>' : '<a class="page-link" href="#" aria-label="Next"><span class="disabled">&rsaquo;</span></a></li> <li class="page-item"><a class="page-link" href="#" aria-label="Last Page"><span class="disabled">&raquo;</span></a>';

$sql .=" LIMIT :limit OFFSET :offset";
$req = $this->bdd->prepare($sql);
Expand Down
9 changes: 6 additions & 3 deletions views/view_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<div class="col-lg-3">

<h1 class="my-4">Catégories</h1>
<form action ="?controller=index&action=orderBy" method="POST">
<form action ="index.php" method="GET">
<input type="hidden" name="controller" value="index"/>
<input type="hidden" name="action" value="orderBy"/>

<div class="list-group">
<?php foreach($data['categories'] as $indice => $value){
?>
Expand Down Expand Up @@ -111,9 +114,9 @@
<li class="page-item"><?php echo $data['prevlink']; ?></li>
<?php for($i=1; $i<=$data['pages'];$i++){ ?>
<?php if($data['page']==$i){ ?>
<li class="page-item active"><a class="page-link" href="?controller=index&action=orderBy&tri=<?= $data['typeAffichage'] ?>&page=<?=$i?>"><?=$i?></a></li>
<li class="page-item active"><a class="page-link" href="?controller=index&idCategory='.$categorie.'&action=orderBy&tri=<?= $data['typeAffichage'] ?>&page=<?=$i?>"><?=$i?></a></li>
<?php }else{ ?>
<li class="page-item"><a class="page-link" href="?controller=index&action=orderBy&tri=<?= $data['typeAffichage'] ?>&page=<?=$i?>"><?=$i?></a></li>
<li class="page-item"><a class="page-link" href="?controller=index&action=orderBy&idCategory='.$categorie.'&tri=<?= $data['typeAffichage'] ?>&page=<?=$i?>"><?=$i?></a></li>
<?php } ?>
<?php
}
Expand Down

0 comments on commit 240b90a

Please sign in to comment.