CPMFetch show parent categories CPMFetch show parent categories
 

News:

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

Main Menu

CPMFetch show parent categories

Started by anniesp04, August 22, 2022, 03:57:34 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

anniesp04

Hello!

I'd like to know if there's an easy way to show all parent categories of an album using CPMfetch (making it look like the gallery breadcrumbs). I'd like to list my updated albums on my site showing the structure used on the gallery ( Magazine Scans > 2022 > Album title).

Using the following code, I can display only one level of parent categories (in the example above '2022'):

include_once $cpmfetch;
$objCpm = new cpm( $cpmconfig );
$objCpm->cpm_setReturnType("resultset");
$images = $objCpm->cpm_getAlbumListFrom( 'album=1,2,3,4,5,6', 1, 6);
foreach ($images as $image => $img) {
echo '<a href="' . $site_url . 'thumbnails.php?album=' . $img[pAid] . '"' . $target . '>' . $img[cName] . ' - ' . $img[aTitle] . '<br>';
}
$objCpm->cpm_close();


Getting the categories using $objCpm->cpm_getCategoryList(); and doing a series of foreach loops (one for each level of parent categories) I was kind of able to get the result, but with an enormous and most likely not efficient code, I'm not very good at coding, so I'm wondering if it's possible to get this result in a more practical (and scalable) way.

If anyone can point me in the right direction it'd be very much appreciated.

Thanks.