Advanced search  

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

Pages: [1] 2   Go Down

Author Topic: Thumbnail for Category with nested categories  (Read 14512 times)

0 Members and 1 Guest are viewing this topic.

Drew Fulton

  • Coppermine newbie
  • Offline Offline
  • Posts: 17
Thumbnail for Category with nested categories
« on: June 29, 2006, 02:14:41 pm »

I have a complex system of nested Categories that are based of biological taxonomy (I am a nature photographer).  For example I may have a category like this.

Birds (cat)
  -> Passeriformes (cat)
        -> Parulidae (cat)
               -> Yellow Warbler (album)

Is there any way to get both the Birds category and the Passeriformes category to have thumbnails?  I tried creating an album in there and making it only visible to me but that doesn't work cuase no one else can see them. 

Thanks for the help.

Drew
« Last Edit: June 30, 2006, 01:18:32 pm by Paver »
Logged

Gizmo

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1015
    • BullsEye Photos
Re: Thumbnail for Category with nested categories
« Reply #1 on: June 29, 2006, 02:19:16 pm »

Here's the link to the section in the manual for adding info and photos to categories: http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#cat_cp.
Logged
Did you read the manual first???? Taking 2 minutes to backup your files can save you hours of wondering what you screwed up.
Billy Bullock - BullsEyePhotos Blog of Indecision

Drew Fulton

  • Coppermine newbie
  • Offline Offline
  • Posts: 17
Re: Thumbnail for Category with nested categories
« Reply #2 on: June 29, 2006, 02:23:40 pm »

Thanks Gizmo,
  I have read through that several times and the problem is this line at the end of it.

"You can only assign a picture to the category only if you have an album with images nested directly within it"

I need to assign a picture to a category that has another category with albums nested within it, not a category that has an album nested directly. 

Any ideas for a work around?

Drew
Logged

Gizmo

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1015
    • BullsEye Photos
Re: Thumbnail for Category with nested categories
« Reply #3 on: June 29, 2006, 02:57:26 pm »

Yes... my mistake. Without adding an album with a single photo, you may need to edit the database table for the category but I would wait for a dev or someone who may have an answer if there is a way before doing this.  :-\ Sorry...
Logged
Did you read the manual first???? Taking 2 minutes to backup your files can save you hours of wondering what you screwed up.
Billy Bullock - BullsEyePhotos Blog of Indecision

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Thumbnail for Category with nested categories
« Reply #4 on: June 29, 2006, 04:50:33 pm »

Ok, here's a mod to do what you want.  As noted in posts below, this mod will not do what was requested.  This mod will pull in the ancestors of the current category, not the children.  Keep reading this thread for the correct solution.

Modify the file catmgr.php in the function form_alb_thumb by replacing this line:
Code: [Select]
$results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND {$CONFIG['TABLE_ALBUMS']}.category = '$cid' AND approved='YES' ORDER BY filename");with this block of lines:
Code: [Select]
    // MOD - Comment next line to replace with the following mod block
    // $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND {$CONFIG['TABLE_ALBUMS']}.category = '$cid' AND approved='YES' ORDER BY filename");

    // MOD - show all pictures from category ancestry

    // Get the ancestry of all categories
    // - Should modify to only get the ancestry of the current category
    $vQuery = "SELECT cid, parent, name FROM " . $CONFIG['TABLE_CATEGORIES'] . " WHERE 1";
    $vResult = cpg_db_query($vQuery);
    $vRes = cpg_db_fetch_rowset($vResult);
    mysql_free_result($vResult);
    foreach ($vRes as $vResI => $vResV) {
        $vResRow = $vRes[$vResI];
        $catParent[$vResRow['cid']] = $vResRow['parent'];
        $catName[$vResRow['cid']] = $vResRow['name'];
    }
    $catAnces = array();
    foreach ($catParent as $cid_id => $cid_parent) {
        $catAnces[$cid_id] = '';
        while ($cid_parent != 0) {
            $catAnces[$cid_id] = $cid_parent . ($catAnces[$cid_id]?','.$catAnces[$cid_id]:'');
            $cid_parent = $catParent[$cid_parent];
        }
    }

    // Pull out the ancestry of the current category
    $catAncestors = $catAnces[$cid] . ($catAnces[$cid] ? ',' : '') . $cid;
    $catQuery = ($catAncestors ? "IN ({$catAncestors})" : "=''");

    // Now do the query for all ancestor categories
    if ($catAncestors) {
        $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND {$CONFIG['TABLE_ALBUMS']}.category $catQuery AND approved='YES' ORDER BY filename");
    } 
    // MOD - END

It's not an efficient mod because it pulls in the ancestry of all categories, then picks out the one you are editting.  I pulled this code from a mod to upload.php I posted on this thread.  I don't have time to fiddle with it yet, but I don't think it should slow down the category editting noticeably unless you have hundreds of categories (which you might at some point if you are doing a taxonomy).  If it is slowing things down or you merely would like some help with more efficient code in the future, let me know.
« Last Edit: June 29, 2006, 06:28:28 pm by Paver »
Logged

Drew Fulton

  • Coppermine newbie
  • Offline Offline
  • Posts: 17
Re: Thumbnail for Category with nested categories
« Reply #5 on: June 29, 2006, 05:22:19 pm »

Hey Paver,
  Thanks for your offer to help.  I just uploaded the new catmgr.php file and it doesn't seem to make any change at all.  I still can't select a thumbnail for the upper level categories, only those low level categories that have albums with images.  Any other ideas?

Drew
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Thumbnail for Category with nested categories
« Reply #6 on: June 29, 2006, 05:25:14 pm »

Heh.  I did the opposite of what you want - you want the children categories, not the ancestors.  I guess I read your post a little too quickly.  Let me look into it.
Logged

Drew Fulton

  • Coppermine newbie
  • Offline Offline
  • Posts: 17
Re: Thumbnail for Category with nested categories
« Reply #7 on: June 29, 2006, 05:39:44 pm »

Haha, I was thinking that might have been what you did.  No rush, I am running the automatically installed version from GoDaddy and realized I need to upgrade to 1.4.8 so I will be doing that for a while.

Thanks again for your help.

Drew
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Thumbnail for Category with nested categories
« Reply #8 on: June 29, 2006, 06:30:38 pm »

Ok.  Try this.  <fingers crossed>

Modify catmgr.php, function form_alb_thumb by replacing this line:
Code: [Select]
$results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND {$CONFIG['TABLE_ALBUMS']}.category = '$cid' AND approved='YES' ORDER BY filename");with this block:
Code: [Select]
    // MOD - Comment next line to replace with the following mod block
    // $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND {$CONFIG['TABLE_ALBUMS']}.category = '$cid' AND approved='YES' ORDER BY filename");

    // MOD - show all pictures from children categories
    $catChildren = '';
    $totalcat_cid_list = $cid ? array($cid) : false;
    while ($totalcat_cid_list) {
        $totalcat_cid = array_pop($totalcat_cid_list);
        $totalcat_result = cpg_db_query("SELECT cid FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = {$totalcat_cid}");
        while ($totalcat_row = mysql_fetch_array($totalcat_result)) {
            array_push($totalcat_cid_list, $totalcat_row['cid']);
        }
        mysql_free_result($totalcat_result);
        $catChildren .= ($catChildren ? ',' : '') . $totalcat_cid;
    }
    if ($catChildren) {
        $catQuery = ($catChildren ? "IN ({$catChildren})" : "=''");
        $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND {$CONFIG['TABLE_ALBUMS']}.category $catQuery AND approved='YES' ORDER BY filename");
    } 
    // MOD - END

Let me know if this is the correct feature you want.  This code is based on this mod to the CPGOcat plugin.
Logged

Drew Fulton

  • Coppermine newbie
  • Offline Offline
  • Posts: 17
Re: Thumbnail for Category with nested categories
« Reply #9 on: June 29, 2006, 07:41:00 pm »

Paver,
  Getting so close. 

  Your code allows me to add a thumbnail in the Category manager but now I can't get it to display it when you are browsing the gallery.

Here's the link:

http://www.infinitehorizonsphotography.com/galleries/index.php?cat=2

I have now added a thumbnail to the Pelecaniformes Category in the Category manager but as you can see, its not displaying.

Thanks again.

Drew
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Thumbnail for Category with nested categories
« Reply #10 on: June 30, 2006, 04:17:30 am »

Ok, I think I found it.  In file index.php, in the function get_subcat_data, look for the following lines:
Code: [Select]
                if ($pic_count == 0 && $album_count == 0) {
                    $user_thumb = $ident;
                    $cat_data[] = array($link, $subcat['description'], 'cat_thumb' => $user_thumb);
and comment out the second line as shown:
Code: [Select]
                if ($pic_count == 0 && $album_count == 0) {
                    // $user_thumb = $ident;  // MOD - to allow cat thumbs for no-album parent categories
                    $cat_data[] = array($link, $subcat['description'], 'cat_thumb' => $user_thumb);
I added in the comment afterwards so that you'll know this is a mod to the default script.  Before you do an upgrade to later versions of Coppermine, you should have a list of mods you made so you can re-apply them after the upgrade.  Having a set comment like // MOD - makes it easier to make a list if you don't have one already.

I think your request is a useful feature for the next major version of Coppermine (1.5) - as an option of course.  I'll look into it.

Let me know if this works and if there are any other issues.
Logged

Drew Fulton

  • Coppermine newbie
  • Offline Offline
  • Posts: 17
Re: Thumbnail for Category with nested categories
« Reply #11 on: June 30, 2006, 05:56:22 am »

That does it! 

Thanks so much Paver. 

I must say that I have dealt with a lot of software companies, many whom I have paid large bucks for their software and I have never had service like this.

Thanks so much.

Drew
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Thumbnail for Category with nested categories
« Reply #12 on: June 30, 2006, 01:57:29 pm »

You're welcome.  Those are very kind words.  I appreciate it.
Logged

PKIDelirium

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Thumbnail for Category with nested categories
« Reply #13 on: October 17, 2006, 04:26:27 am »

I have a quick question regarding this mod. This doesn't alter the database, correct?
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Thumbnail for Category with nested categories
« Reply #14 on: October 17, 2006, 06:44:12 am »

I have a quick question regarding this mod. This doesn't alter the database, correct?

Correct.  The only queries in the mod are SELECT queries, which are read-only (generally and specifically in this case).
Logged

PKIDelirium

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Thumbnail for Category with nested categories
« Reply #15 on: January 23, 2007, 06:28:31 am »

Hello,

I recently upgraded to 1.4.10. As soon as I upgraded I re-applied this mod. Tonight I needed to add a new category and category thumbnail to it for the first time since upgrading, and I am unable to edit or add a thumbnail to ANY category. The thumbnails all display correctly on regular cats as well as the ones this mod was written for, but the thumbnail controlled no longer appears in the Categories panel.
Logged

PKIDelirium

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Thumbnail for Category with nested categories
« Reply #16 on: February 09, 2007, 05:20:19 am »

Bump.

Does anyone know why this did not function correctly after upgrade to 1.4.10? My gallery is slightly difficult to navigate without this in place.
Logged

Drew Fulton

  • Coppermine newbie
  • Offline Offline
  • Posts: 17
Thumbnail for Category with nested categories...
« Reply #17 on: January 17, 2008, 10:52:59 pm »

Back in June of 2006, I set up my first Coppermine gallery and posted this question.  Paver was quick to come up with a great solution for me.  I am now putting together a new site and am finally updating to a new version of coppermine and this time it isn't working.  Here is the link to the previous thread.  Anyone have any ideas on how to remedy the problem?


http://forum.coppermine-gallery.net/index.php?topic=33310.0

Thank you very much for any and all help.

Drew
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Thumbnail for Category with nested categories
« Reply #18 on: January 18, 2008, 08:07:59 am »

Merged your new thread with the existing one.
Logged

AndrewC

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: Thumbnail for Category with nested categories
« Reply #19 on: March 21, 2010, 10:34:04 am »

.....
I think your request is a useful feature for the next major version of Coppermine (1.5) - as an option of course.  I'll look into it.
.....

Did it ever make it into 1.5.x ?  Searching the forums it seems not

http://forum.coppermine-gallery.net/index.php/topic,61903.0.html

... but perhaps someone has a clever workaround or it is about to happen.

Andrew
Logged
Pages: [1] 2   Go Up
 

Page created in 0.023 seconds with 20 queries.