Bitrix Site Manager

InitSorting

InitSorting(
 mixed page = false,
 string by_var = "by",
 string order_var = "order"
)

The function InitSorting initialises parameters of sorting stored in the session, if the sorting was not explicitly specified. If the sorting is explicitly specified the function stores parameters of sorting in the session.

Note
The function handles variables of the global scope. Take it into account when creating the main component files.

Parameters

ParameterDescription
page A page for which the sorting is initialised. The false value initialises sorting for the current page.
Optional. False by default.
by_var The name of a variable in which the sorting field ID is passed.
Optional. The default value is "by".
order_var The name of a variable containing the sorting direction: "asc" (ascending) or "desc" (descending).
Optional. "order" by default.

See Also

Example



<?
// if variables $by and $order are explicitly specified, their values are stored in the session
// otherwise they are initialised with values stored in the session
InitSorting();
$rsUsers = CUser::GetList($by, $order);
?>
<table>
    <tr> 
        <td>ID<br><?=SortingEx("s_id")?></td>
        <td>Login<br><?=SortingEx("s_name")?></td>
    </tr>
    ...
</table>