forum.coppermine-gallery.net

Support => cpg1.6.x Support => cpg1.6 miscellaneous => Topic started by: anniesp04 on August 22, 2022, 03:57:34 pm

Title: CPMFetch show parent categories
Post by: anniesp04 on August 22, 2022, 03:57:34 pm
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'):
Code: [Select]
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.