Friday, January 24, 2014

Wordpress: Modifying NextGEN Gallery files to display gallery and album descriptions in NextGen Basic Extended Album view...

Long title, short story: We used the NextGEN Basic Extended Album view and created custom css for it. Our client wanted to display description texts at both the album and gallery level, so we filled in the appropriate fields in the Admin forms, but nothing was displayed.

Searching on the web told me that many others run in to this problem, but I didn't find a solution that worked.

I came up with a not too elegant solution that works:

1. Open the album file: 

/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_basic_album/templates/extended.php

2. Insert this code before <div class="ngg-albumoverview">

 <?php   
 $my_album_id = $displayed_gallery->container_ids[0];  
 $my_result = mysql_query("SELECT * FROM wp_ngg_album WHERE id='".$my_album_id."' LIMIT 1");  
 $my_row = mysql_fetch_assoc($my_result);  
 if($my_row['albumdesc'] != '') {  
   echo $my_row['albumdesc'];  
   echo '<br />';  
   echo '<br />';  
 };  
 ?>  

3. Open the gallery file:

/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_basic_gallery/templates/thumbnails/index.php

4. Insert this code before <div class="ngg-galleryoverview" id="ngg-gallery-<?php echo_h($displayed_gallery_id)?>-<?php echo_h($current_page)?>">


 <?php   
 $my_gallery_id = $displayed_gallery->container_ids[0];  
 $my_result = mysql_query("SELECT * FROM wp_ngg_gallery WHERE gid='".$my_gallery_id."' LIMIT 1");  
 $my_row = mysql_fetch_assoc($my_result);  
 if($my_row['galdesc'] != '') {  
      echo $my_row['galdesc'];  
      echo '<br />';  
      echo '<br />';  
 };  
 ?>  



///////////////////////////////////////
If you are using other layouts, you have to modify other files...