CPMFetch show parent categories CPMFetch show parent categories
 

News:

CPG Release 1.6.27
change DB IP storage fields to accommodate IPv6 addresses
remove use of E_STRICT (PHP 8.4 deprecated)
update README to reflect new website
align code with new .com CPG website
correct deprecation in captcha

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.