<?
$arAvailableSort = array(
"name" => Array("name", "asc"),
"price" => Array('PROPERTY_MINIMUM_PRICE', "asc"),
"date" => Array('PROPERTY_NEWPRODUCT', "desc"),
"quantity" => Array('CATALOG_QUANTITY ', "asc"),
);
$sort = array_key_exists("sort", $_REQUEST) && array_key_exists(ToLower($_REQUEST["sort"]), $arAvailableSort) ? $arAvailableSort[ToLower($_REQUEST["sort"])][0] : "name";
$sort_order = array_key_exists("order", $_REQUEST) && in_array(ToLower($_REQUEST["order"]), Array("asc", "desc")) ? ToLower($_REQUEST["order"]) : $arAvailableSort[$sort][1];
?>
<div class="catalog-item-sorting">
<label>Сортировать по:</label>
<?$r=0;?>
<?foreach ($arAvailableSort as $key => $val):
$className = $sort == $val[0] ? 'selected' : '';
if ($className)
$className .= $sort_order == 'asc' ? ' asc' : ' desc';
$newSort = $sort == $val[0] ? $sort_order == 'desc' ? 'asc' : 'desc' : $arAvailableSort[$key][1];
if($r==0) $pname = "Названию";
if($r==1) $pname = "Цене";
if($r==2) $pname = "Новизне";
if($r==3) $pname = "Количеству";
?>
<a href="<?=$APPLICATION->GetCurPageParam('sort='.$key.'&order='.$newSort, array('sort', 'order'))?>" class="<?=$className?>" rel="nofollow"><?=$pname?> </a>
<?$r++?>
<?endforeach;?>
</div>
|