I'm trying to modify a bit of the code on the PopupGallery 4.2.2 so that the gallery index images show up on the correct parent pages. (My image pages are nested so that there's a main Images page and then several subImages pages.)
I've been modifying the fgtags.php file in order to this but my problem is I can't find a way to call up the current page's ID in a variable I've called $pageid(I'm a persistent newbie to PHP). Right now, I just have it set to $pageid = 27, which is the page ID for one of the nested pages.
Here's what I have set up.
function fg_gallery_index($image_class='gallerythumb', $index_style='table', $show=true)
{
global $table_prefix, $wpdb;
$pageid = 27; //the code here should retrieve the current page's ID but I can't get anything to work
//now load the collection records
// changed to order the gallery by the parent pages and then by the post title
// the where statement limits the index images to the ones whose parent page is the current page
$fg_imagedata = $wpdb->get_results('SELECT ' . $table_prefix . 'gallerypage.ID, ' . $table_prefix . 'gallerypage.gallerypath, ' . $table_prefix . 'gallerypage.indextext, ' . $table_prefix . 'gallerycollection.thumbfile, ' . $table_prefix . 'posts.post_title
FROM ' . $table_prefix . 'gallerypage
LEFT JOIN ' . $table_prefix . 'posts ON ' . $table_prefix . 'gallerypage.ID = ' . $table_prefix . 'posts.ID
LEFT JOIN ' . $table_prefix . 'gallerycollection ON ' . $table_prefix . 'gallerypage.ID = ' . $table_prefix . 'gallerycollection.ID WHERE ' . $table_prefix . 'gallerycollection.indexfile = 1 AND ' . $table_prefix . 'posts.post_parent = ' . $pageid . '
ORDER BY ' . $table_prefix . 'posts.post_parent, ' . $table_prefix . 'posts.post_title;');// the following lines are unchanged
Also, I'd like to add a piece of code (an OR statement in the WHERE condition?) that makes it so if you're on the main page (post_parent of that page would be 0 (zero) and none of the gallery index image's posts.post_parent variable would match that page) all of the photos in the index show up. This would happen on the main "Images" page.