E
E
Egor Tregubenko2016-07-18 12:55:21
PHP
Egor Tregubenko, 2016-07-18 12:55:21

How to bind 'current' to another link (Bitrix filter)?

There is this piece of code:

<div class="sort_filter">
          <?	
          $arAvailableSort = array();
          $arSorts = $arParams["SORT_BUTTONS"];
          if(in_array("POPULARITY", $arSorts)){
            $arAvailableSort["SHOWS"] = array("SHOWS", "desc");
          }
          if(in_array("NAME", $arSorts)){
            $arAvailableSort["NAME"] = array("NAME", "asc");
          }
          if(in_array("PRICE", $arSorts)){ 
            $arSortPrices = $arParams["SORT_PRICES"];
            if($arSortPrices == "MINIMUM_PRICE" || $arSortPrices == "MAXIMUM_PRICE"){
              $arAvailableSort["PRICE"] = array("PROPERTY_".$arSortPrices, "desc");
            }
            else{
              $price = CCatalogGroup::GetList(array(), array("NAME" => $arParams["SORT_PRICES"]), false, false, array("ID", "NAME"))->GetNext();
              $arAvailableSort["PRICE"] = array("CATALOG_PRICE_".$price["ID"], "desc"); 
            }
          }
          if(in_array("QUANTITY", $arSorts)){
            $arAvailableSort["CATALOG_AVAILABLE"] = array("QUANTITY", "desc");
          }
          $sort = "SHOWS";
          if((array_key_exists("sort", $_REQUEST) && array_key_exists(ToUpper($_REQUEST["sort"]), $arAvailableSort)) || (array_key_exists("sort", $_SESSION) && array_key_exists(ToUpper($_SESSION["sort"]), $arAvailableSort)) || $arParams["ELEMENT_SORT_FIELD"]){
            if($_REQUEST["sort"]){
              $sort = ToUpper($_REQUEST["sort"]); 
              $_SESSION["sort"] = ToUpper($_REQUEST["sort"]);
            }
            elseif($_SESSION["sort"]){
              $sort = ToUpper($_SESSION["sort"]);
            }
            else{
              $sort = ToUpper($arParams["ELEMENT_SORT_FIELD"]);
            }
          }

          $sort_order=$arAvailableSort[$sort][1];
          if((array_key_exists("order", $_REQUEST) && in_array(ToLower($_REQUEST["order"]), Array("asc", "desc"))) || (array_key_exists("order", $_REQUEST) && in_array(ToLower($_REQUEST["order"]), Array("asc", "desc")) ) || $arParams["ELEMENT_SORT_ORDER"]){
            if($_REQUEST["order"]){
              $sort_order = $_REQUEST["order"];
              $_SESSION["order"] = $_REQUEST["order"];
            }
            elseif($_SESSION["order"]){
              $sort_order = $_SESSION["order"];
            }
            else{
              $sort_order = ToLower($arParams["ELEMENT_SORT_ORDER"]);
            }
          }
          ?>
          <?foreach($arAvailableSort as $key => $val):?>
            <?$newSort = $sort_order == 'desc' ? 'asc' : 'desc';?>
            <a rel="nofollow" href="<?=$APPLICATION->GetCurPageParam('sort='.$key.'&order='.$newSort, 	array('sort', 'order'))?>" class="sort_btn <?=($sort == $key ? 'current' : '')?> <?=$sort_order?> <?=$key?>" rel="nofollow">
              <i class="icon" title="<?=GetMessage('SECT_SORT_'.$key)?>"></i><span><?=GetMessage('SECT_SORT_'.$key)?></span><i class="arr"></i>
            </a>
          <?endforeach;?>
          <?
          if($sort == "PRICE"){
            $sort = $arAvailableSort["PRICE"][0];
          }
          if($sort == "CATALOG_AVAILABLE"){
            $sort = "CATALOG_QUANTITY";
          }
          ?>
        </div>

it displays a sorting filter on the page: By popularity , alphabetically , by price
I need to change what would be "popularity" by default, help guys)
this type of link is formed:
213.159.214.90/catalog/planshety/apple_ipad_air_2/...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Emelyanov, 2016-07-18
@babarun

What is specified in the component settings in the field "ELEMENT_SORT_FIELD" ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question