Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2   Go Down

Author Topic: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category  (Read 34422 times)

0 Members and 1 Guest are viewing this topic.

PerlAddict

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 3

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:

Code: [Select]
$cat_data[] = array($link, $ident . $subcat['description'], $album_count, $pic_count);
Code: [Select]
$cat_data[] = array($link, $subcat['description'], 'cat_thumb' => $user_thumb);
Code: [Select]
$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:
Code: [Select]
, "cat_id" => $subcat['cid']

So your lines should now look like this (using the first line of code as an example):
Code: [Select]
$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:

Code: [Select]
        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):

Code: [Select]
        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]
« Last Edit: August 15, 2006, 05:19:03 pm by Nibbler »
Logged

Nibbler

  • Guest
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #1 on: August 15, 2006, 05:19:27 pm »

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.
Logged

PerlAddict

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 3
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #2 on: August 15, 2006, 05:39:27 pm »

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

All4yu

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 17
    • All4yu.com - Association sportive et culturelle serbe en France
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #3 on: August 25, 2006, 08:23:47 pm »

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

Thanks
Logged

PerlAddict

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 3
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #4 on: August 31, 2006, 10:12:12 pm »

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.
Logged

joeboxer

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
    • RealAdventures
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #5 on: November 03, 2006, 05:58:33 am »

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

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #6 on: November 10, 2006, 09:14:55 pm »

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?
Logged

Nibbler

  • Guest
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #7 on: November 10, 2006, 09:29:41 pm »

Post the actual error message.
Logged

joeboxer

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
    • RealAdventures
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #8 on: November 10, 2006, 09:49:43 pm »

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

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #9 on: November 13, 2006, 02:03:17 pm »

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? 
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #10 on: November 13, 2006, 02:16:17 pm »

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.
Logged

Fitzkilt

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #11 on: November 13, 2006, 02:17:54 pm »

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
Logged

Gephri

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 235
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #12 on: December 13, 2006, 10:39:08 pm »

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

/index.php
Code: [Select]
    * Notice line 770: Undefined index: system_icon
and

/themes/(my theme)/theme.php
Code: [Select]
    * 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!
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #13 on: December 14, 2006, 05:55:32 am »

Turn notices off if they don't mean anything to you.
Logged

ardeo

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #14 on: May 10, 2007, 08:57:49 pm »

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
Logged

Ahtub

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #15 on: September 13, 2007, 08:19:54 am »

Hi,

Please, correct this code for last version Coppermine!!!
Logged

Ahtub

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #16 on: September 13, 2007, 08:39:52 am »

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.
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #17 on: September 13, 2007, 08:42:17 am »

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

Ahtub

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #18 on: September 13, 2007, 12:28:51 pm »

Thanks, all really works.
Logged

deve

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Quick and Dirty Hack to Add Thumbnail to "Users Galleries" Category
« Reply #19 on: January 16, 2008, 10:46:07 am »

works great it whould be very nice if you can show all users galeri thumbnails :)
Logged
Pages: [1] 2   Go Up
 

Page created in 0.026 seconds with 21 queries.