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]   Go Down

Author Topic: Possible to set category thumbnail if all albums are keyword based in category?  (Read 16294 times)

0 Members and 1 Guest are viewing this topic.

tenacjed

  • Coppermine novice
  • *
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 33
    • Waggoner Photography

Site: http://www.waggonerphotography.com/gallery2/index.php?cat=0

Example Category of keyword based albums only: http://www.waggonerphotography.com/gallery2/index.php?cat=63

I have several categories with albums that are keyword based only.  I was wondering if it is possible to set a category thumbnail when the albums in the category are keyword based.  I can set thumbnails on the category where the pictures were actually uploaded to without issue.

Thanks!
John W
Logged
What a long... strange trip it's been!!!

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery

I don't see anything in the database that would prevent this.The category (in cpg_categories) would need the 'thumb' value set to the 'pid' of the desired picture...

The interface determines the list of eligible pictures in catmgr.php on line 208 at 1.5.26 looking for pictures in albums contained in the category.
The logic here would need to be altered to also include pictures with a keyword(picture can have more than one - space separated by default, but could be another character based on config value) that matches the album keyword...

Need to dig a little deeper into 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

tenacjed

  • Coppermine novice
  • *
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 33
    • Waggoner Photography

I was a little surprised when I went to the category and the set picture was not there.  I was able to set all the thumbnail for the keyword based albums.  I thought for sure the category would be able to do the same.  No problem setting thumbnail on category that contained albums where the pictures were uploaded.
Logged
What a long... strange trip it's been!!!

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764

Please reply to this post so I get reminded to have a look at it later. Thanks.
Logged

tenacjed

  • Coppermine novice
  • *
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 33
    • Waggoner Photography

Thank you for any help you can provide!
Logged
What a long... strange trip it's been!!!

tenacjed

  • Coppermine novice
  • *
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 33
    • Waggoner Photography

Just replying as a reminder for Andre to look into this one.  Hopefully I am not replying too soon!  Thanks again for any help that you can provide!
Logged
What a long... strange trip it's been!!!

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764

This seems to work for me as expected. Open catmgr.php, find
Code: [Select]
    if ($cid == USER_GAL_CAT) {
        $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE a.category > ".FIRST_USER_CAT." AND approved = 'YES' ORDER BY filename");
    } else {
        $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE a.category = $cid AND approved = 'YES' ORDER BY filename");
    }
and replace with
Code: [Select]
    $keyword = '';
    $result = cpg_db_query("SELECT DISTINCT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = $cid AND keyword != ''");
    if (mysql_num_rows($result)) {
        while ($row = mysql_fetch_assoc($result)) {
            $keyword .= "OR (keywords LIKE '%{$row['keyword']}%') ";
        }
    }
    mysql_free_result($result);

    if ($cid == USER_GAL_CAT) {
        $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE (a.category > ".FIRST_USER_CAT." $keyword) AND approved = 'YES' ORDER BY filename");
    } else {
        $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE (a.category = $cid $keyword) AND approved = 'YES' ORDER BY filename");
    }

Please report any unexpected behavior.
Logged

tenacjed

  • Coppermine novice
  • *
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 33
    • Waggoner Photography

Αndré,

Thank you very much, this worked perfectly!
Logged
What a long... strange trip it's been!!!

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764

Here's improved code, as the previous code doesn't take care of the user gallery category. Please replace the previous code with this one and test again if it still works as expected:
Code: [Select]
    function cpg_get_alb_keyword($sql) {
        $keyword = '';
        $result = cpg_db_query($sql);
        if (mysql_num_rows($result)) {
            while ($row = mysql_fetch_assoc($result)) {
                $keyword .= "OR (keywords LIKE '%{$row['keyword']}%') ";
            }
        }
        mysql_free_result($result);
        return $keyword;
    }

    if ($cid == USER_GAL_CAT) {
        $keyword = cpg_get_alb_keyword("SELECT DISTINCT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE category > ".FIRST_USER_CAT." AND keyword != ''");
        $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE (a.category > ".FIRST_USER_CAT." $keyword) AND approved = 'YES' ORDER BY filename");
    } else {
        $keyword = cpg_get_alb_keyword("SELECT DISTINCT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = $cid AND keyword != ''");
        $results = cpg_db_query("SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE (a.category = $cid $keyword) AND approved = 'YES' ORDER BY filename");
    }
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764

Can someone please verify that the last code works as expected? Thanks.
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery

Setting up a test for this... But a little confused..

The case of non-user categories is simple... And I think has been tested... Just creating a new category and having albums in it with no directly added pics - just keywords...  I'll apply your code and verify this again.

For user galleries, even if photos are directly added, where do I specify the category photo?  It seems to show last uploaded for each when viewing index.php?cat=1 - and I see no place to set a 'category photo'.

If I define a new user and add a single album specifying a keyword used in public albums... It displays the public photos with that keyword when logged on as that user and selecting 'My Gallery' (index.php?cat=10006) - but does not show in 'User Gallery' view (index.php?cat=1)
User keyword only albums don't seem to appear in the count of Albums in User Galleries on index.php...

I'm not sure what to test here for the user galleries case...
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764

If you open the category manager and edit a category, you can set a category thumbnail. Before the change, Coppermine just regards pictures of albums that reside in the current category. After the change, Coppermine also regards linked pictures. This means the linked pictures will be listed additionally. If there are no "regular" pictures, you wasn't able to set a category thumb, as the option wasn't displayed.
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery

OK... I was trying to do it as a user for my user galleries - and not as Admin to the overall User Gallery category...
Will test and report.
Thanks for the clarification.
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery

Tested on 1.5.26 and SVN 8660.
Linked pictures are now selectable for category thumbnails - including the overall 'user gallery' category.
Categories containing only albums with no direct photos now display the option to select a thumbnail from the list of linked photos.

Looks good to me!
Thanks!!
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me

Looks good to me too. Great work all.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764

Committed proposed fix in SVN revision 8663.
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 20 queries.