// получаем параметры сортировки из запроса
if (strlen($_REQUEST["ORDER_BY"])<=0)
$ORDER_BY = $arForum["ORDER_BY"];
else
$ORDER_BY = $_REQUEST["ORDER_BY"];
if (strlen($_REQUEST["ORDER_DIRECTION"])<=0)
$ORDER_DIRECTION = $arForum["ORDER_DIRECTION"];
else
$ORDER_DIRECTION = $_REQUEST["ORDER_DIRECTION"];
if ($ORDER_BY=="T")
$strOrderBy = "TITLE";
elseif ($ORDER_BY=="N")
$strOrderBy = "POSTS";
elseif ($ORDER_BY=="A")
$strOrderBy = "USER_START_NAME";
elseif ($ORDER_BY=="V")
$strOrderBy = "VIEWS";
elseif ($ORDER_BY=="D")
$strOrderBy = "START_DATE";
else
$strOrderBy = "LAST_POST_DATE";
if (strtoupper($ORDER_DIRECTION) == "ASC")
$strOrderDir = "ASC";
else
$strOrderDir = "DESC";
// задаем порядок сортировки для выборки
$arOrder = array("SORT"=>"ASC", $strOrderBy=>$strOrderDir);
...
$db_Topic = CForumTopic::GetListEx($arOrder, $arFilter);
|