Bitrix Site Manager

CForumNew::GetList

CDBResult
GetList(
 [array arOrder [,
 array arFilter]]
);

The method GetList returns a filtered and sorted list of forums.

Parameters

ParameterDescription
arOrder An array in the format Array(by1=>order1[, by2=>order2 [, ..]]), where:

by - the field by which the list is to be sorted. The following values are possible:
  • ID - the forum ID;
  • LID - the forum language;
  • NAME - the forum name;
  • ACTIVE - active state;
  • MODERATION - specifies the forum is moderated;
  • FORUM_GROUP_ID - the forum group ID;
  • TOPICS - number of threads in the forum;
  • POSTS - number of posts in the forum;
  • LAST_POST_DATE - the date the last post was created;
  • SORT - sort index;
order - sort order. The following values are possible:
  • ASC - ascending;
  • DESC - descending;
Optional. The default value is Array("SORT"=>"ASC")
arFilter An array in the format array("filter field"=>"filter value" [, ...]). The "filter field" can be one of the following:
  • LID - the forum language;
  • ACTIVE - active state;
  • ID - the forum ID;
  • FORUM_GROUP_ID - the forum group ID;
  • TOPICS - number of threads in the forum;
  • POSTS - number of posts in the forum;
  • TEXT - entry in the forum name or description;
  • PERMS - access permission for the forum (an array of two indexes, the first is a list of user group ID's, and the second is the access permission code).
The filtered field may contain one of the following filter check specifiers before the name:
  • "!" - not equal;
  • "<" - less than;
  • "<=" - less or equal;
  • ">" - more than;
  • ">=" - more or equal.
Optional. By default, records are not filtered.

Return Values

Returns an instance of the CDBResult class.

See Also

  • CDBResult
  • Forum fields

    Example


    
    <?
    // Display a list of forums that the current user can at least read.
    // First sort the list by sort index, then by the forum name
    $arFilter = array();
    if (!$USER->IsAdmin())
    {
      $arFilter["PERMS"] = array($USER->GetGroups(), 'A');
      $arFilter["ACTIVE"] = "Y";
    }
    $arOrder = array("SORT"=>"ASC", "NAME"=>"ASC");
    $db_Forum = CForumNew::GetList($arOrder, $arFilter);
    while ($ar_Forum = $db_Forum->Fetch())
    {
      echo $ar_Forum["NAME"]."<br>";
    }
    ?>