nggShowAlbumTags

NggShowAlbumTags() - create a gallery based on the tags 20140119: Added template and sort.

Description

nggShowAlbumTags( (string) $taglist, (string) $template = '', (string) $sorting = 'ASC' ); 

Parameters (3)

0. $taglist (string)
List of tags as csv
1. $template — Optional. (string) => ''
The template.
2. $sorting — Optional. (string) => 'ASC'
The sorting.

Usage

  1. if ( !function_exists( 'nggShowAlbumTags' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextcellent-gallery/nggfunctions.php'; 
  3.  
  4. // list of tags as csv 
  5. $taglist = ''; 
  6.  
  7. // The template. 
  8. $template = ''; 
  9.  
  10. // The sorting. 
  11. $sorting = 'ASC'; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = nggShowAlbumTags($taglist, $template, $sorting); 
  15.  

Defined (1)

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

/nggfunctions.php  
  1. function nggShowAlbumTags($taglist, $template='', $sorting = 'ASC') { 
  2.  
  3. global $wpdb, $nggRewrite; 
  4.  
  5. // $_GET from wp_query 
  6. $tag = get_query_var('gallerytag'); 
  7. $pageid = get_query_var('pageid'); 
  8.  
  9. // look for gallerytag variable 
  10. if ( $pageid == get_the_ID() || !is_home() ) { 
  11. if (!empty( $tag )) { 
  12.  
  13. // avoid this evil code $sql = 'SELECT name FROM wp_ngg_tags WHERE slug = \'slug\' union select concat(0x7c, user_login, 0x7c, user_pass, 0x7c) from wp_users WHERE 1 = 1'; 
  14. $slug = esc_attr( $tag ); 
  15. $tagname = $wpdb->get_var( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE slug = %s", $slug ) ); 
  16. $out = '<div id="albumnav"><span><a href="' . get_permalink() . '" title="' . __('Overview', 'nggallery') .' ">'.__('Overview', 'nggallery').'</a> | '.$tagname.'</span></div>'; 
  17. $out .= nggShowGalleryTags($slug, $template, $sorting); 
  18. return $out; 
  19.  
  20.  
  21. // get now the related images 
  22. $picturelist = nggTags::get_album_images($taglist); 
  23.  
  24. // go on if not empty 
  25. if ( empty($picturelist) ) 
  26. return; 
  27.  
  28. // re-structure the object that we can use the standard template 
  29. foreach ($picturelist as $key => $picture) { 
  30. $picturelist[$key]->previewpic = $picture->pid; 
  31. $picturelist[$key]->previewname = $picture->filename; 
  32. $picturelist[$key]->previewurl = site_url() . '/' . $picture->path . '/thumbs/thumbs_' . $picture->filename; 
  33. $picturelist[$key]->counter = $picture->count; 
  34. $picturelist[$key]->title = $picture->name; 
  35. $picturelist[$key]->pagelink = $nggRewrite->get_permalink( array('gallerytag'=>$picture->slug) ); 
  36.  
  37. //TODO: Add pagination later 
  38. $navigation = '<div class="ngg-clear"></div>'; 
  39.  
  40. // create the output 
  41. $out = nggGallery::capture ('album-compact', array ('album' => 0, 'galleries' => $picturelist, 'pagination' => $navigation) ); 
  42.  
  43. $out = apply_filters('ngg_show_album_tags_content', $out, $taglist); 
  44.  
  45. return $out;