nggShowGallery

Wrapper to I_Displayed_Gallery_Renderer->display_images(); this will display a basic thumbnails gallery.

Description

nggShowGallery( (int) $galleryID, (string) $template = '', (bool) $images = false ); 

Parameters (3)

0. $galleryid (int)
| string ID or slug from a gallery
1. $template — Optional. (string) => ''
name for a template file, look for gallery-$template
2. $images — Optional. (bool) => false
number of images per page

Usage

  1. if ( !function_exists( 'nggShowGallery' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextcellent-gallery/nggfunctions.php'; 
  3.  
  4. // | string ID or slug from a gallery 
  5. $galleryid = -1; 
  6.  
  7. // (optional) name for a template file, look for gallery-$template 
  8. $template = ''; 
  9.  
  10. // (optional) number of images per page 
  11. $images = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = nggShowGallery($galleryid, $template, $images); 
  15.  

Defined (1)

The function is defined in the following location(s).

/nggfunctions.php  
  1. function nggShowGallery( $galleryID, $template = '', $images = false ) { 
  2.  
  3. global $nggRewrite, $nggdb; 
  4.  
  5. $ngg_options = nggGallery::get_option(ngg_options); 
  6.  
  7. //Set sort order value, if not used (upgrade issue) 
  8. $ngg_options['galSort'] = ($ngg_options['galSort']) ? $ngg_options['galSort'] : 'pid'; 
  9. $ngg_options['galSortDir'] = ($ngg_options['galSortDir'] == 'DESC') ? 'DESC' : 'ASC'; 
  10.  
  11. // get gallery values 
  12. //TODO: Use pagination limits here to reduce memory needs 
  13. //20130106:shouldn't call it statically if is not... 
  14. //$picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']); 
  15. //array of nggImage objects returned 
  16. $picturelist = $nggdb->get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']); 
  17.  
  18. if ( !$picturelist ) 
  19. return __('[Gallery not found]', 'nggallery'); 
  20.  
  21. // If we have we slug instead the id, we should extract the ID from the first image 
  22. if ( !is_numeric($galleryID) ) { 
  23. $first_image = current($picturelist); 
  24. $galleryID = intval($first_image->gid); 
  25.  
  26. // $_GET from wp_query 
  27. $show = get_query_var('show'); 
  28. $pid = get_query_var('pid'); 
  29. $pageid = get_query_var('pageid'); 
  30.  
  31. // set $show if slideshow first 
  32. if ( empty( $show ) AND ($ngg_options['galShowOrder'] == 'slide')) { 
  33. if ( is_home() ) 
  34. $pageid = get_the_ID(); 
  35.  
  36. $show = 'slide'; 
  37.  
  38. // filter to call up the imagebrowser instead of the gallery 
  39. // use in your theme : add_action( 'ngg_show_imagebrowser_first', create_function('', 'return true;') ); 
  40. if ( apply_filters('ngg_show_imagebrowser_first', false, $galleryID ) && $show != 'thumbnails' ) { 
  41. $out = nggShowImageBrowser( $galleryID, $template ); 
  42. return $out; 
  43.  
  44. // go on only on this page 
  45. if ( !is_home() || $pageid == get_the_ID() ) { 
  46.  
  47. // 1st look for ImageBrowser link 
  48. if ( !empty($pid) && $ngg_options['galImgBrowser'] && ($template != 'carousel') ) { 
  49. $out = nggShowImageBrowser( $galleryID, $template ); 
  50. return $out; 
  51.  
  52. // 2nd look for slideshow 
  53. if ( $show == 'slide' ) { 
  54. $args['show'] = "gallery"; 
  55. $out = '<div class="ngg-galleryoverview">'; 
  56. $out .= '<div class="slideshowlink"><a class="slideshowlink" href="' . $nggRewrite->get_permalink($args) . '">'.nggGallery::i18n($ngg_options['galTextGallery']).'</a></div>'; 
  57. $out .= nggShowSlideshow($galleryID); 
  58. $out .= '</div>'."\n"; 
  59. $out .= '<div class="ngg-clear"></div>'."\n"; 
  60. return $out; 
  61.  
  62. // get all picture with this galleryid 
  63. if ( is_array($picturelist) ) 
  64. $out = nggCreateGallery($picturelist, $galleryID, $template, $images); 
  65.  
  66. $out = apply_filters('ngg_show_gallery_content', $out, intval($galleryID)); 
  67. return $out;