forum.coppermine-gallery.net

Support => cpg1.6.x Support => cpg1.6 themes (visuals) => Topic started by: Hanna. on June 12, 2018, 05:30:58 pm

Title: Latest images fetch; need to specify category
Post by: Hanna. on June 12, 2018, 05:30:58 pm
Hi all!. I have been using this amazing set up for fetching images from Coppermine in HTML. However, now I need some assistance to specify category from where to fetch latest images:

Code: [Select]
define('IN_COPPERMINE', true);
define('INDEX_PHP', true);
require('include/init.inc.php');

//How many items you want to show in your get_photo script
if(isset($_GET['nb'])) {
     $thumb_per_page=$_GET['nb'];
} else {
     $thumb_per_page = 36;
}
$thumb_count = 36;
$lower_limit = 0;

if(isset($_GET['album'])){
    $album = $_GET['album'];
}

//If it is a numeric album get the name and set variables
if ((is_numeric($album))){
     $album_name_keyword = get_album_name($album);
     $CURRENT_CAT_NAME = $album_name_keyword['title'];
     $ALBUM_SET = "AND aid IN (".(int)$_GET['album'].")".$ALBUM_SET;
     //Set the album to last uploaded
     [b]$album = 'lastup';[/b]
}

//If the album is not set set it to lastup - this is the default
if(!isset($album)){
     $album = 'lastup';
}


//Changes these to point to your site if the following is not giving correct results.
$link_url = $CONFIG['ecards_more_pic_target']."displayimage.php?pos=-";
$image_url = $CONFIG['ecards_more_pic_target']."albums/";


$data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page);


foreach($data AS $picture) {
    $thumb_url = "$image_url$picture[filepath]$CONFIG[thumb_pfx]$picture[filename]";
    $description = '<a target="_blank" href="' . $link_url . $picture['pid'] . '"><img class="gallery" width="90" src="' . $thumb_url . '" border="0" alt="Photos"/></a> ';
    echo $description;

}

?>

The BOLD is where I tried to simply add &cat=89 as it goes in the URL, but it won't work. I hope it does not take too long to help me get this code to grab lastup IN THE cat 89 (for example). Thank you in advance!
Title: Re: Latest images fetch; need to specify category
Post by: gmc on July 06, 2018, 09:04:50 pm
Missed this post - just saw it looking around...
Don't see anything in BOLD - but think I understand what you are doing - but specifics on how you are invoking could help.

CPMFETCH was written to do what you are asking (and more). As you see - it can get more complicated as you are trying to mimic more of what CPG does. CPMFETCH is standalone code (not a true plugin) that uses its own functions to access CPG data.
 
To do it yourself - since the pics don't reference categories directly, would need to get a list of albums in the category -then find pics in the list of albums.  Looks like get_pic_data will accept a $cat (GLOBAL) - been a while since I chased that code to see what it does with it though.
You said you were passing in '&cat=89' in URL - but I see no place where you reference it in the code...
Title: Re: Latest images fetch; need to specify category
Post by: ron4mac on July 07, 2018, 02:08:27 pm
Would this type of cpmfectch call get you what you want?

Code: [Select]
cpm_viewLastAddedMediaFrom('cat=-89', 4, 4, '');
Title: Re: Latest images fetch; need to specify category
Post by: Hanna. on July 09, 2018, 06:23:32 pm
The code I posted is in a separate php file that I fetch by putting the <iframe src> code, so it is not really a cpm fetch (Ive seen them before). However, to specify category I tried on this line:

Quote
//If it is a numeric album get the name and set variables
if ((is_numeric($album))){
     $album_name_keyword = get_album_name($album);
     $CURRENT_CAT_NAME = $album_name_keyword['title'];
     $ALBUM_SET = "AND aid IN (".(int)$_GET['album'].")".$ALBUM_SET;
     //Set the album to last uploaded
     $album = 'lastup';
}

the  $album = 'lastup'; -- I tried  $album = 'cat=89'; but nothing happens...
Title: Re: Latest images fetch; need to specify category
Post by: gmc on July 09, 2018, 06:41:50 pm
The code I posted is in a separate php file that I fetch by putting the <iframe src> code, so it is not really a cpm fetch (Ive seen them before). However, to specify category I tried on this line:

the  $album = 'lastup'; -- I tried  $album = 'cat=89'; but nothing happens...

'lastup' is a meta album name that CPG recognizes - which is why this works.
'cat=89' is not... so no match will be found in CPG code.

To do this outside of cpmfetch, you would need to identify all albums in the desired category, then find the latest picture(s) in that collection of albums - while continuing to respect private album restrictions, etc...

Is there a problem with using cpmfetch?