Advanced search  

News:

cpg1.5.46 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter recently discovered vulnerabilities. It is important that all users who run version cpg1.5.44 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Latest images fetch; need to specify category  (Read 446 times)

0 Members and 1 Guest are viewing this topic.

Hanna.

  • Coppermine frequent poster
  • ***
  • Country: us
  • Offline Offline
  • Gender: Female
  • Posts: 131
  • webstar
Latest images fetch; need to specify category
« 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!
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 738
    • GMC Design Photo Gallery
Re: Latest images fetch; need to specify category
« Reply #1 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...
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

ron4mac

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Posts: 912
Re: Latest images fetch; need to specify category
« Reply #2 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, '');
Logged

Hanna.

  • Coppermine frequent poster
  • ***
  • Country: us
  • Offline Offline
  • Gender: Female
  • Posts: 131
  • webstar
Re: Latest images fetch; need to specify category
« Reply #3 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...
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 738
    • GMC Design Photo Gallery
Re: Latest images fetch; need to specify category
« Reply #4 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?
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 20 queries.