Notifications
Clear all

[Tutorial] Turning category image into a link

5 Posts
3 Users
0 Reactions
6,636 Views
(@jacynthe)
Posts: 242
Estimable Member
Topic starter
 

I wanted to do that on my site so I just decided to get my act together and try not to break anything. It took me some time seeing as I'm no coding genius, but I did manage it. Yay!!! πŸ˜€

Anyhow, here's what you need to do if you want to do that yourself.

open browse/categories.php and look for:


$cat->assign("image", ($cats['image'] && file_exists("$skindir/images/".$cats['image']) ? "<img src=""$skindir/images/".$cats['image'"]."" alt="".$cats['category']."" border=1 title="".$cats['category']."">" : ""));

replace with


$cat->assign("image", ($cats['image'] && file_exists("$skindir/images/".$cats['image']) ? "<a href=""browse.php?type=categories&amp;id=".$cats['catid'"].""><img src=""$skindir/images/".$cats['image'"]."" alt="".$cats['category']."" border=1 title="".$cats['category'].""></a>" : ""));

You can see this in action here.

Furthermore, I decided I wanted to remove the brackets that surrounded the number of stories because I wanted to merge together the story count and description (as shown in the link above).

So if you decide you want to do that as well, here's what you need to look for in browse/categories.php


$cat->assign("count", "[".$cats['numitems']."]");

replace with:


$cat->assign("count", "".$cats['numitems']."");

then in your skin's categories.tpl you need to have the following code


<!-- START BLOCK : categoryblock -->
{image}<br />
{link}<br />
{count} stories {description}
<p>&nbsp;</p>
<!-- END BLOCK : categoryblock -->

Okay. I better go to bed now because it's nearing 3:30am and I work in 4 and a half hours... I'll regret staying up this late to redo all my categories images!  😐


Jacynthe

Archives: http://fanfics.e-authors.net
Version: 3.5.3
Modified? Somewhat...
PHP:  5.3.3
MySQL: 5.0.91-community

 
Posted : 07/09/2007 4:22 am
(@tammy)
Posts: 2577
Member Moderator
 

Good job. 

FYI, you don't need the empty "" in this line:


$cat->assign("count", "".$cats['numitems']."");

You can write it as:


$cat->assign("count", $cats['numitems']);


 
Posted : 07/09/2007 10:15 am
(@jacynthe)
Posts: 242
Estimable Member
Topic starter
 

Thanks Tammy! I'll fix that then. πŸ™‚


Jacynthe

Archives: http://fanfics.e-authors.net
Version: 3.5.3
Modified? Somewhat...
PHP:  5.3.3
MySQL: 5.0.91-community

 
Posted : 07/09/2007 10:21 am
Jan_AQ
(@jan_aq)
Posts: 1300
Noble Member
 

Wow, I like! πŸ™‚ Nice idea, Jacynthe, and thanks for sharing it!


Whoever said nothing is impossible never tried slamming a revolving door.

url: https://www.potionsandsnitches.org/fanfiction
php: 7.4.33 msql: 5.6.51-community GPL
efic version: 3.5.5 latest patches: yes
bridges: none mods: challenges, tracker, story end, beta, word

 
Posted : 07/09/2007 2:44 pm
(@jacynthe)
Posts: 242
Estimable Member
Topic starter
 

My pleasure Jan. Once in a while I get a good idea - and what's even more rare: once in a while I figure it out on my own. LOL


Jacynthe

Archives: http://fanfics.e-authors.net
Version: 3.5.3
Modified? Somewhat...
PHP:  5.3.3
MySQL: 5.0.91-community

 
Posted : 09/09/2007 8:31 pm
Share: