- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
function _sortSetting( &$smarty, $urlToSort )
{
// $sort_string = STRING_PRODUCT_SORT;
// $sort_string = str_replace( "{ASC_NAME}", "<a class='sort_orders' href='".$urlToSort."&sort=name&direction=ASC'>".STRING_ASC."</a>", $sort_string );
// $sort_string = str_replace( "{DESC_NAME}", "<a class='sort_orders' href='".$urlToSort."&sort=name&direction=DESC'>".STRING_DESC."</a>", $sort_string );
// $sort_string = str_replace( "{ASC_PRICE}", "<a class='sort_orders' href='".$urlToSort."&sort=Price&direction=ASC'>".STRING_ASC."</a>", $sort_string );
// $sort_string = str_replace( "{DESC_PRICE}", "<a class='sort_orders' href='".$urlToSort."&sort=Price&direction=DESC'>".STRING_DESC."</a>", $sort_string );
// $sort_string = str_replace( "{ASC_RATING}", "<a class='sort_orders' href='".$urlToSort."&sort=customers_rating&direction=ASC'>".STRING_ASC."</a>", $sort_string );
// $sort_string = str_replace( "{DESC_RATING}", "<a class='sort_orders' href='".$urlToSort."&sort=customers_rating&direction=DESC'>".STRING_DESC."</a>", $sort_string );
$selected = array();
for ($i = 0; $i < 6; ++$i) {
$selected[] = "";
}
$i = null;
if ($_GET["sort"] == "name") {
if ($_GET["direction"] == "ASC") {
$i = 0;
}
else {
$i = 1;
}
}
else if ($_GET["sort"] == "Price") {
if ($_GET["direction"] == "ASC") {
$i = 2;
}
else {
$i = 3;
}
}
else if ($_GET["sort"] == "customers_rating") {
if ($_GET["direction"] == "ASC") {
$i = 4;
}
else {
$i = 5;
}
}
$selected[$i] = " selected=\"selected\"";
$sort_string = <<<HTML
<script type="text/javascript">
function go(form) {
var i = form.sort.selectedIndex;
var direction = "DESC";
if (i % 2 == 0) {
direction = "ASC";
}
var sort = "customers_rating";
if (i < 2) {
sort = "name";
}
else if (i < 4) {
sort = "Price";
}
var url = "{$urlToSort}&sort=" + sort +"&direction=" + direction;
// alert(url);
window.location = url;
}
</script>
<form action="#">
<p>
Сортировать по: <select name="sort" onchange="javascript: go(this.form);">
<option value="0"{$selected[0]}>имени / возрастанию</option>
<option value="1"{$selected[1]}>имени / убыванию</option>
<option value="2"{$selected[2]}>цене / возрастанию</option>
<option value="3"{$selected[3]}>цене / убыванию</option>
<option value="4"{$selected[4]}>оценке / возрастанию</option>
<option value="5"{$selected[5]}>оценке / убыванию</option>
</select>
</p>
</form>
HTML;
$smarty->assign( "string_product_sort", $sort_string );
}