You are here

function rotor_get_items in Rotor Banner 5

Same name and namespace in other branches
  1. 6 rotor.module \rotor_get_items()

This is a theme function to act as a wrapper for the image either case that we are using imagecache or not.

Parameters

integer $limit How many nodes to fetch (0 for unlimited):

boolean $random Should the items be returned in a random order:

Return value

array A list of published rotor_item nodes.

2 calls to rotor_get_items()
rotor_admin_form in ./rotor.module
Admin settings form page.
rotor_block_content in ./rotor.module
Returns the block content.

File

./rotor.module, line 476
A rotor banner consists in a set of images that will be changing. This module is made using jquery.

Code

function rotor_get_items($limit = 0, $random = FALSE) {
  $items = array();
  if (module_exists('nodequeue') && variable_get('rotor_nodequeue', 0) > 0) {
    $queue_id = variable_get('rotor_nodequeue', 0);
    $result = db_query("SELECT n.nid FROM {node} n LEFT JOIN {nodequeue_nodes} nn ON n.nid = nn.nid WHERE nn.sqid = %d AND n.status = 1 ORDER BY nn.position", $queue_id);
  }
  else {
    $query = "SELECT nid FROM {node} WHERE type = 'rotor_item' AND status=1";
    if ($random) {
      $query .= ' ORDER BY RAND()';
    }
    if ($limit) {
      $query .= ' LIMIT ' . (int) $limit;
    }
    $result = db_query($query);
  }
  while ($node = db_fetch_array($result)) {
    $items[] = node_load($node);
  }
  return $items;
}