You are here

function node_gallery_api_get_item_position in Node Gallery 7

Returns the position (starting at one) of the image in the gallery list.

Parameters

int $ngid: The nid of the gallery to use.

int $nid: The nid of the image to return the position of.

Return value

int The position of the image in the list of published images in the gallery.

2 calls to node_gallery_api_get_item_position()
node_gallery_api_get_item_navigator in ./node_gallery_api.module
Builds an array with the data necessary to navigate a gallery.
node_gallery_api_seek_from_current_item in ./node_gallery_api.inc
Returns the nid of the image +/-N steps away from the current image node.

File

./node_gallery_api.inc, line 819
Node Gallery API function

Code

function node_gallery_api_get_item_position($ngid, $nid, $reset = FALSE) {
  static $item_position = array();
  if (!isset($item_position[$ngid]) || $reset) {
    if (!$reset && ($cache = cache_get('node_gallery:' . $ngid . ':item_position')) && !empty($cache->data)) {
      $item_position[$ngid] = $cache->data;
    }
    else {
      _node_gallery_api_cache_sorted_item_nids($ngid);
      $cache = cache_get('node_gallery:' . $ngid . ':item_position');
      $item_position[$ngid] = $cache->data;
    }
  }
  return $item_position[$ngid][$nid];
}