Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
 

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

Main Menu

Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category

Started by PerlAddict, August 15, 2006, 04:54:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PerlAddict

Well, I got my CPG up and running how I want it for the most part, with only a few major cosmetic changes left (like listing the users in the "Users Gallery" in the same layout as the main category page instead of like thumbnails). But one of the things I searched for and kept seeing people say wasn't available was a way to add an icon to the "Users Gallery" category on the main index page.

Of course, there's always a way to do something. Maybe not dynamically or as gracefully as we would like, but it can be done. So here's what I did to add an icon to my users gallery:

Find the following three lines in index.php:

$cat_data[] = array($link, $ident . $subcat['description'], $album_count, $pic_count);

$cat_data[] = array($link, $subcat['description'], 'cat_thumb' => $user_thumb);

$cat_data[] = array($link, $subcat['description'], $album_count, $pic_count, 'cat_albums' => $cat_albums, 'cat_thumb' => $user_thumb);

Now, after the last value in each array, between the word and the closing parenthesis, add this:
, "cat_id" => $subcat['cid']


So your lines should now look like this (using the first line of code as an example):
$cat_data[] = array($link, $subcat['description'], 'cat_thumb' => $user_thumb, "cat_id" => $subcat['cid']);


Now, I'm assuming that the special "Users Galleries" category always has a category ID of "1" ... if by chance it doesn't, just replace the number "1" in the following bit of code with the correct category number. For the image, naturally replace it with a link to the thumbnail you want to be shown and with the appropriate width and height dimensions. Like I said, it's not pretty or elegant, but it gets the job done as far as having a thumbnail there.

In your "themes/THEMENAME/themes.php" file (and/or your "includes/themes.inc.php" file, depending on how you set up and manage themes), find this line. It will be within the "function theme_display_cat_list" function:

        if (!isset($category['cat_thumb'])) { $category['cat_thumb'] = ''; }


Change that code to this, remembering to update the image source, width, and height in the <img src> tag to point to the picture you want as your thumbnail for the Users Galleries category (in the example below, I'm just using a thumb for a picture I'd already uploaded into one of my galleries):

        if (!isset($category['cat_thumb'])) {
        if ($category['cat_id'] == USER_GAL_CAT) {
        $category['cat_thumb'] = '<a href="index.php?cat=' . USER_GAL_CAT . '"><img src="albums/userpics/10002/thumb_members_icon.jpg" class="image" width="50" height="50" border="0" alt="" /></a>';
        } else {
        $category['cat_thumb'] = '';
        }
        }



There you go. You now have a thumbnail for your Users Galleries section.

[Added code tags and corrected some minor issues - Nibbler]

Nibbler

If you don't have theme_display_cat_list() in your theme.php you should copy the version from the sample theme into your theme.php and then modify your copy as suggested above. include/themes.inc.php should not be modified.

Thanks for your contribution.

PerlAddict

Very much appreciated, Nibbler! Thanks for making those tidbits a bit more user friendly. :)

All4yu

PerlAddict, do you have an example on a website ?
I would like to see the add-on on the CPG

Thanks

PerlAddict

http://www.pcsar.net/gallery/ is where I currently have mine up. There's really not much to see, though ... it's just a thumbnail next to the user's gallery like what you would have on any of the other non-user galleries.

joeboxer

Looks like a great solution, but I'm having trouble getting it to work on my system.

I have adjusted the 3 lines in index.php adding as the last element of the array: , "cat_id" => $subcat['cid']

I have copied the theme_display_cat_list() function from /themes/samples/theme.php into /themes/mytheme/theme.php

Then I added the 7 lines of code to /themes/themename/theme.php as suggested. I adjusted the <img src> to point to the appropriate thumbnail picture.

It doesn't have any effect. Is there a step that I'm missing?

Thanks for your help, Joe

Fitzkilt

Not working here, either....think I'm a bit confused on editing the theme.php in my Kubrick theme, which does not contain the theme_display_cat_list() function anywhere. If I attempt to add it, I get a "cannot re-declare" error.

I made the first three changes as suggested but I'm lost. Has anyone else got this to work?


joeboxer

I still have not been able to get it to work. There are no error messages, but also no picture.

I've checked over the code 10 times, but can't find anything I've missed. What's the best way to track the problem down?

You can see the gallery at: http://www.realadventures.com/gallery/

Fitzkilt

Okay, I got this to work but not by adding function theme_display_cat_list to my theme.php (Kubrick theme, heavily modified). I had to edit the function in themes.inc.php itself to get it to work but...for some reason the thumbnail isn't displaying, just the old red "X". The dimensions and path to the image are correct so what did I miss?

Nibbler: I realize you suggest not editing the themes.inc.php file but for me this isn't working any other way...is it possible to pull this function out of themes.inc.php and move it to my theme.php? 

Joachim Müller

Everything that can be done by editing include/themes.inc.php can be accomplished by editing themes/yourtheme/theme.php as well. If you insist on editing themes.inc.php although we told you not to do so, you're on your own with this.

Fitzkilt

Nevermind...the path was incorrect. Well, not really; the image I uploaded had an extra "_" in the file name.

Thank you, PerlAddict, for a very nice mod. And thanks for your valuable input, Nibbler. It's working now. :D

Gephri

Installed and working fine - but when I look at my Debug Info I see the following:

/index.php
    * Notice line 770: Undefined index: system_icon

and

/themes/(my theme)/theme.php

    * Notice line 1616: Undefined offset: 2
    * Notice line 1617: Undefined offset: 3
points to this code:
            $params = array('{CAT_TITLE}' => $category[0],
                '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => $category[1],
                '{CAT_ALBUMS}' => $category['cat_albums'],
                '{ALB_COUNT}' => $category[2],
                '{PIC_COUNT}' => $category[3],
                );
            echo template_eval($template, $params);
        } else {
            $params = array('{CAT_TITLE}' => $category[0],
                '{CAT_THUMB}' => $category['cat_thumb'],
[line 1616]                '{CAT_DESC}' => $category[1],
[line 1617]                '{CAT_ALBUMS}' => '',
                '{ALB_COUNT}' => $category[2],
                '{PIC_COUNT}' => $category[3],
                );
            echo template_eval($template, $params);


can you suggest how to fix this?
thanks!

Joachim Müller


ardeo

Hi,

I'm trying to use this mod on my CPG 1.4.10 gallery, and can't get it to work.  Basically, nothing happens at all.  Strangely enough, I was able to successfully install it in my other gallery which is still running .09... Has anyone been able to use this mod with the new version of coppermine?  If so, did you have to change anything to get it to work?

thanks!
roland

Ahtub


Ahtub

I need to make thumbnail for personal galleries on the main page. Enough the simple picture which have been not connected with concrete galleries. Otherwise the input in personal galleries is imperceptible for users.

Sami

@ardeo & Ahtub:
Mod should works with 1.4.x , both of you probably didn't add it properly
‍I don't answer to PM with support question
Please post your issue to related board


deve

works great it whould be very nice if you can show all users galeri thumbnails :)