function _forum_get_topic_order

Gets topic sorting information based on an integer code.

Parameters

$sortby: One of the following integers indicating the sort criteria:

  • 1: Date - newest first.
  • 2: Date - oldest first.
  • 3: Posts with the most comments first.
  • 4: Posts with the least comments first.

Return value

An array with the following values:

  • field: A field for an SQL query.
  • sort: 'asc' or 'desc'.
1 call to _forum_get_topic_order()
forum_get_topics in modules/forum/forum.module
Gets all the topics in a forum.

File

modules/forum/forum.module, line 1317

Code

function _forum_get_topic_order($sortby) {
  switch ($sortby) {
    case 1:
      return array(
        'field' => 'f.last_comment_timestamp',
        'sort' => 'desc',
      );
      break;

    case 2:
      return array(
        'field' => 'f.last_comment_timestamp',
        'sort' => 'asc',
      );
      break;

    case 3:
      return array(
        'field' => 'f.comment_count',
        'sort' => 'desc',
      );
      break;

    case 4:
      return array(
        'field' => 'f.comment_count',
        'sort' => 'asc',
      );
      break;

  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.