Created
February 27, 2018 12:40
-
-
Save morozVA/8e843517f1a77fe6878a69a6094351fa to your computer and use it in GitHub Desktop.
evo сортировка
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="sort_count" name="sort_count" method="get" action="[~[*id*]~]"> | |
<div class="col-md-6 col-sm-6 col-xs-12"> | |
<div class="sort-by"> | |
<label>Сортировка:</label> | |
<div class="select-sort-by"> | |
<select class="inputbox" name="order" id="order" onChange="window.location=window.location.pathname+'?sort='+this.value;"> | |
<option [!selected? ¶m=`sort` &znach=`pagetitle`!] class="pagetitle" value="pagetitle" selected="selected">По алфавиту</option> | |
<option [!selected? ¶m=`sort` &znach=`asc`!] class="asc" value="asc">По возрастанию цены</option> | |
<option [!selected? ¶m=`sort` &znach=`desc`!] class="desc" value="desc">По убыванию цены</option> | |
<option [!selected? ¶m=`sort` &znach=`random`!] class="random" value="random" >Без сортировки</option> | |
</select> | |
</div> | |
</div> | |
</div> | |
</form> | |
Сниппет selected задает выбранному option атрибут selected | |
<?php | |
if ($_REQUEST[$param]==$znach) { | |
echo "selected"; | |
} | |
?> | |
Вызов Ditto | |
[!Ditto? | |
&tpl=`catalog-product_tpl-grid` | |
&filter=`template,9,1` | |
&extenders=`request` | |
&depth=`4` | |
&parents=`[*id*]` | |
&display=`all` | |
&paginate=`1` | |
&display=`20` | |
&orderBy=`[[filter_order]]` | |
!] | |
Сниппет filter_order | |
<?php | |
$output = 'pagetitle ASC'; | |
$sort = $_GET['sort']; | |
$sort = strip_tags($sort); | |
$sort = htmlspecialchars($sort); | |
$sort = mysql_escape_string($sort); | |
switch($sort) { | |
case 'asc' : $output = 'price ASC'; break; | |
case 'desc' : $output = 'price DESC'; break; | |
case 'pagetitle' : $output = 'pagetitle ASC'; break; | |
case 'random' : $output = ''; break; | |
} | |
return $output; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment