<? DEW-CODE.COM  





Lost Password?
No account yet? Register

Downloads

Assorted scripts  (1)
DewNewPHPLinks  (9)

Dew-Code Newsfeed

Resources



Dew-Code
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Category Photo? (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Category Photo?
#1637
webking (User)
Fresh Boarder
Posts: 17
graphgraph
User Offline Click here to see the profile of this user
Category Photo? 2 Years ago Karma: 0  
Hi,

So if I want to add a photo for the each of the category, how would I do that?

It would be nice to have Category photos.

Thanks.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#1638
Dewed (Admin)
Admin
Posts: 610
graph
User Offline Click here to see the profile of this user
Dew-Code.com
Re:Category Photo? 2 Years ago Karma: 10  
Since every category can have one of four options that affect it's display, how to get category picture differs,
depending on which option you have your categories set to use..

I'll assume your categories use the "Top" option, since that is what is assigned by default..

So, make a backup of /include/functions.php and open the file for editing in any plain text editor
such as Notepad.

Locate the function "top_children" , which is called when a category is set to use the "Top" option, mine starts around line #297

Within that function, you should find the following 3 lines of code, mine are around line #419

Code:

$cat_html .= "&nbsp;<a class=\"subCategory\" href=\"./directory/" . $gtc_array[cat_id] . ".html"; if ($usesession =="yes"){$cat_html .= "?". session_name()."=".session_id() ."";} $cat_html .= "\">" . eregi_replace("_"," ",$gtc_array[cat_name]) . "</a>";
So, you could create a directory, I'll call mine "catpics" and upload your category pictures to it. The files would all need to be the same type of image, jpg, gif, png.. whatever you prefer. You will also probably want to ensure all the images have identical dimensions, in my example, I'll use PNG images... After creating the "catpics" directory and uploading my images to it, 1.png for category #1, 2.png for category #2 and so on...
Code:

$cat_html .= "&nbsp;<a class=\"subCategory\" href=\"./directory/" . $gtc_array[cat_id] . ".html"; if ($usesession =="yes"){$cat_html .= "?". session_name()."=".session_id() ."";} $cat_html .= "\">"; // start category pictures if (is_file('/INSTALLDIR/catpics/'.$gtc_array[cat_id].'.png')){ $cat_html .='<img src="/INSTALLDIR/catpics/'.$gtc_array[cat_id].'.png" border=0 align=middle />'; } // end category pictures $cat_html .= eregi_replace("_"," ",$gtc_array[cat_name]) . "</a>";
 
Report to moderator   Logged Logged  
 
Last Edit: 2011/05/31 13:53 By Dewed.
 
Nothing to it but to Dew it !
Dew-Code.com
  The administrator has disabled public write access.
#1639
webking (User)
Fresh Boarder
Posts: 17
graphgraph
User Offline Click here to see the profile of this user
Re:Category Photo? 2 Years ago Karma: 0  
Thank you very much Dewed! I'll give it a try and will let you know all know how it goes.

Thanks again!
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#1644
webking (User)
Fresh Boarder
Posts: 17
graphgraph
User Offline Click here to see the profile of this user
Re:Category Photo? 2 Years ago Karma: 0  
Does not seem to work for me.

Replace the top code with the bottom one or insert the bottom code below the top code? It seems like this is in SubCategory read instead of mainCategory.

Is it supposed to be in the MainCategory instead at line 667?

Code:

$cat_html .= $main_cw_table . "\t<tr>\r\n\t\t\t\t<td><a class=\"mainCategory\" ";
I've tried both and it didn't work. hmmm.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#1645
Dewed (Admin)
Admin
Posts: 610
graph
User Offline Click here to see the profile of this user
Dew-Code.com
Re:Category Photo? 2 Years ago Karma: 10  
In my previous post I meant find this ...
replace with this ...

And yes, I got the functions mixed up but the code should be easily moved.

Of course if the image file does not exist, it won't be displayed.

I'm assuming you changed INSTALLDIR to your actual installation directory? Possibly it is working as desired, just isn't finding the image, maybe using a relative path to your catpics directory

<img src="./catpics/'.$gtc_array[cat_id].'.png"


Code:

$cat_html .= $main_cw_table . "\t<tr>\r\n\t\t\t\t<td><a class=\"mainCategory\" "; $cat_html .= "href=\"./directory/" . $gc_array[cat_id]. ".html"; if ($usesession =="yes"){$cat_html .= "?". session_name()."=".session_id() ."&amp;";} $cat_html .= "\">" . $cat_name = eregi_replace("_"," ",$gc_array[cat_name]). "</a>";
becomes
Code:

$cat_html .= $main_cw_table . "\t<tr>\r\n\t\t\t\t<td><a class=\"mainCategory\" "; $cat_html .= "href=\"./directory/" . $gc_array[cat_id]. ".html"; if ($usesession =="yes"){$cat_html .= "?". session_name()."=".session_id() ."&amp;";} $cat_html .= "\">"; // start category pictures if (is_file('./catpics/'.$gc_array[cat_id].'.png')){ $cat_html .='<img src="/INSTALLDIR/catpics/'.$gtc_array[cat_id].'.png" border=0 align=middle />'; } // end category pictures $cat_html .= $cat_name = eregi_replace("_"," ",$gc_array[cat_name]). "</a>";
 
Report to moderator   Logged Logged  
 
Last Edit: 2011/06/02 16:02 By Dewed.
 
Nothing to it but to Dew it !
Dew-Code.com
  The administrator has disabled public write access.
#1646
webking (User)
Fresh Boarder
Posts: 17
graphgraph
User Offline Click here to see the profile of this user
Re:Category Photo? 2 Years ago Karma: 0  
That code works great! Thanks!

One minor issue.

An array variable was misspelled. It should be "gc_array" instead of "gtc_array"

Code:

$cat_html .='<img src="/INSTALLDIR/catpics/'.$gc_array[cat_id].'.png" border=0 align=middle />'; }
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
get the latest posts directly to your desktop
Freelance Jobs
Newsflash
Interested in
advertising?

This space for rent!

Sign up for PayPal and start accepting credit card payments instantly.
Copyright Dew-Code 2013