Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to add a list (like a cd track list) of names and links to all images next my nextgen gallery, how can I retrieve this list? (similar to the list in the select object in the Gallery Settings, in the gallery admin page)

share|improve this question
    
Where do you get the data from? –  toscho Dec 9 '12 at 15:06
    
hmmm I thought that there might be a shortcode for that.. right now I simply use a gallery shortcode in a post. I want to add it to the imagebrowser.php template, a simple list of all images in that gallery.. –  Omer Dec 9 '12 at 15:35

2 Answers 2

You may use a function similar to below one to retrieve a list of image properties in a Next-Gen image gallery.

function wp75475_imagelist(){

//http://codex.wordpress.org/Function_Reference/is_plugin_active
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );

if(!is_plugin_active('nextgen-gallery/nggallery.php')){
    return 'NextGen Gallery Plugin is needed to display imagelist';
}

$imagegallery = new nggdb();
$images = $imagegallery->get_gallery('cdtrack');
$imagelist = '';

foreach ($images as $image):
    $imagelist .= $image->$filename;
endforeach;

return $imagelist;

}

For a list of retrievable image properties see properties of nggImage object.

/nextgen-gallery/lib/image.php

share|improve this answer
    
Thanks Upeksha, can I use it in imagebrowser.php ? –  Omer Dec 9 '12 at 16:14
    
Yes, that is possible. (in /yourthemefolder/nggallery/imagebrowser.php) –  Upeksha Dec 9 '12 at 16:27
    
I'm trying, getting no errors, but it doesn't print anything... I wrapped the code with <?php code ?> and put it at the top of the page, right below <div class="ngg-imagebrowser" id="<?php echo $image->anchor ?>"> –  Omer Dec 9 '12 at 16:39
    
I also tried to use in a post with a plugin that allows php in posts but it didn't work yet... I also replaced "cdtrack" with the name of my gallery –  Omer Dec 9 '12 at 16:57
    
Did you echo the function output? echo wp75475_imagelist(); –  Upeksha Dec 9 '12 at 17:16

Ok, this has worked for me.

<?php 
// get the track list 
global $nggdb;
    $gallery = $nggdb->get_gallery ($galleryID, 'sortorder', 'ASC', true, 0, 0);
?>
<div id="tracklist">
<?php foreach($gallery as $image) { ?>
<div class="single_image" id="image-<?php echo $image->pid; ?>">
    <a href="<?php the_permalink() ?>&pid=<?php echo $image->pid;?>" title="<?php echo $image->title; ?>">
        <?php echo $image->alttext; ?>
    </a>
</div>
<?php } ?>
</div>  
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.