You are here

function _node_gallery_cache_sorted_image_nids in Node Gallery 6.3

Builds the caches for a gallery and saves them to the db.

There are two caches stored for each gallery. One is a sorted array of nids that represents the images in proper search order. The second is an associative array where the key is the nid of the image and the value is that nid's respective position in the list (1-based).

Parameters

$gid: The nid of the gallery to build caches for.

2 calls to _node_gallery_cache_sorted_image_nids()
node_gallery_get_image_list in ./node_gallery.inc
Gets a sorted list of images nids within a gallery.
node_gallery_get_image_position in ./node_gallery.inc
Returns the position (starting at one) of the image in the gallery list.

File

./node_gallery.inc, line 577
Shared functions for node_gallery

Code

function _node_gallery_cache_sorted_image_nids($gid) {
  $image_list = node_gallery_get_image_nids($gid, TRUE, TRUE);
  $image_position = array();
  $position = 1;
  foreach ($image_list as $nid) {
    $image_position[$nid] = $position;
    $position++;
  }
  cache_set('node_gallery:' . $gid . ':image_position', $image_position, 'cache', CACHE_TEMPORARY);
  cache_set('node_gallery:' . $gid . ':image_list', $image_list, 'cache', CACHE_TEMPORARY);
}