Latest images fetch; need to specify category Latest images fetch; need to specify category
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Latest images fetch; need to specify category

Started by Hanna., June 12, 2018, 05:30:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hanna.

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:


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!

gmc

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...
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

ron4mac

Would this type of cpmfectch call get you what you want?

cpm_viewLastAddedMediaFrom('cat=-89', 4, 4, '');

Hanna.

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...

gmc

Quote from: 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:

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?
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money