4images Forum & Community

4images Modifications / Modifikationen => Templates & Styles (Releases & Support) => Topic started by: SLL on January 14, 2003, 10:10:23 AM

Title: [Style] Static icons in the Category frame
Post by: SLL on January 14, 2003, 10:10:23 AM
I've got a number of emails asking how to add static icons in the Category frame. Below is my solution:

- Create icons for each category and name them category[cat_id].gif, for example category1.gif, category2.gif, etc.
This is according to your taste, of course. I'm using 40x40 gif's like this: (http://faces.dalnet.ru/templates/4blue_orange1/images_russian/category1.gif) (http://faces.dalnet.ru/templates/4blue_orange1/images_russian/category2.gif)

- Create the image joinbottom.gif for sub-categories or use mine:(http://faces.dalnet.ru/templates/4blue_orange1/images_russian/joinbottom.gif)

- Place them all into /templates/xxxx/images/ folder (or /templates/xxxx/images_lang/ if you are using multiple languages)

- Change your /templates/xxxx/category_bit.html as follows:

Code: [Select]
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
<td width="50" rowspan="2" align="center" valign="top">
<a href="{cat_url}"><img src="{template_lang_image_url}/category{cat_id}.gif" border="1"></a></td>
<td align="left" valign="top"><a href="{cat_url}" class="maincat">{cat_name}</a>&nbsp;({num_images})</td>
  </tr>
  <tr>
<td align="left" valign="top">{if cat_description}<span class="smalltext">{cat_description}</span><br />{endif cat_description}</td>
  </tr>
</table>
{if sub_cats}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
<td width="50" align="center" valign="top"><img src="{template_lang_image_url}/joinbottom.gif"></td>
<td align="left" valign="top">{sub_cats}</td>
  </tr>
</table>
{endif sub_cats}

- If you do not use multiple languages, change {template_lang_image_url} to {template_image_url}

That's it! Demo at http://faces.dalnet.ru/index.php?l=english (http://faces.dalnet.ru/index.php?l=english)
Title: Static icons in the Category frame
Post by: Shap on February 21, 2003, 02:00:20 AM
VERY nice.. my only question is how do I get it so the text isn't so close to the images?
Title: Static icons in the Category frame
Post by: Shap on February 21, 2003, 02:01:22 AM
ah, nevermind, just figured it out.. great mod!
Title: Static icons in the Category frame
Post by: Shap on February 21, 2003, 02:27:46 AM
ok now I got a problem..

Now my links are messed up, there trying to go to http://www.madfunny.com/{cat_url}

any ideas?
Title: Static icons in the Category frame
Post by: Shap on February 21, 2003, 02:33:39 AM
hmm, weird figured it out, I took the original <a href..... from another template and it works fine not. :idea:
Title: Static icons in the Category frame
Post by: Amosnet on March 10, 2003, 11:40:11 PM
Would be great if you can give me a idea how i impiment it into
the External Random Image from:
http://www.4homepages.de/forum/viewtopic.php?p=19135#19135

Thanks
Title: Static icons in the Category frame
Post by: Fuztug on June 22, 2003, 10:01:14 AM
How do I do it, that it will only show 1 Catimage not category1, category2, category3, categoryn ?

EDIT:
Thx, I figured it myself out!

Thx, Fuz
Title: Static icons in the Category frame
Post by: Fuztug on June 22, 2003, 10:07:20 AM
Hello,
it's me again!

What I do miss is that these subcategories are listed one by one. But I want it, like V@no @ gallery.vano.org, mutual.

How do I do this?

Thx, Fut
Title: Re: Static icons in the Category frame
Post by: RuthE on June 14, 2005, 12:46:10 AM
I don't wish to have images for every category. As I have 500+, is it possible to only have them where there are images? Can the clause be written 'if there is an image' then display it? I'm clueless about code, but I like how this mod works.
Title: Re: Static icons in the Category frame
Post by: Cottelletje on September 05, 2005, 03:25:09 PM
ah, nevermind, just figured it out.. great mod!

how did you do it i have the same problem?
Title: Re: Static icons in the Category frame
Post by: .real on September 29, 2005, 10:35:28 PM
hey thats great, but i have over 200 categorys...
i just need about 12 icons...i get a red x at the other categories. how do i change that? :?


 :arrow: http://aaliyahlegacy.aa.funpic.de/4images/index.php
Title: Re: Static icons in the Category frame
Post by: wydmuch on December 27, 2005, 08:16:19 PM
Great mod. It works as expected.
Luckily I only have 42 categories so far and not too much work creating those thumbs.
http://www.wydmuch.de/4images/index.php
It really improved the whole layout of the page, I think  :)

But I still have to do a lot...
Title: Re: Static icons in the Category frame
Post by: V@no on December 28, 2005, 02:58:36 AM
hey thats great, but i have over 200 categorys...
i just need about 12 icons...i get a red x at the other categories. how do i change that? :?


 :arrow: http://aaliyahlegacy.aa.funpic.de/4images/index.php
Asuming you have allowed php execution in templates (controled by includes/constants.php)
Then try use in the template something like this:
Code: [Select]
<?php
$icon 
"folder.gif";
if (
in_array($this->val_cache['cat_id'], array(1,2,3,4)))
{
  $icon "category".val_cache['cat_id'].".gif";
}
echo 
"<a href=\"".$this->val_cache['cat_url']."\"><img src=\"".$this->val_cache['template_lang_image_url']."/".$icon."\" border=\"1\"></a>";
?>
Replace 1,2,3,4 with the categorie's IDs which you wish to be displayed with the custom icon.
folder.gif image will be used for the categories not from that list

P.S. make sure there is nothing on the same line with <?php and ?> not even a space!

P.P.S. I have not tested this code and typed it directly in the browser, so there is a possibility of an error... :oops:
Title: Re: Static icons in the Category frame
Post by: kandah on January 19, 2006, 12:18:35 PM
Descent solution!
Title: Re: Static icons in the Category frame
Post by: leedzinh on March 12, 2006, 05:55:10 PM
great MOD. My gallery is nicer. My members can choose baby through icon now! You can see in sub-cat at http://www.3xland.com  :wink:
thanks SLL so much!
Title: Re: Static icons in the Category frame
Post by: emilio on April 07, 2006, 11:43:03 AM
hi V@no

this code in which file I must put it?

<?php
$icon = "folder.gif";
if (in_array($this->val_cache['cat_id'], array(1,2,3,4)))
{
  $icon = "category".val_cache['cat_id'].".gif";
}
echo "<a href=\"".$this->val_cache['cat_url']."\"><img src=\"".$this->val_cache['template_lang_image_url']."/".$icon."\" border=\"1\"></a>";
?>

do you have had time to prove it to know if it works?

thanks man

saludos
emilio
Title: Re: Static icons in the Category frame
Post by: V@no on April 07, 2006, 02:28:47 PM
in category_bit.html template
Title: Re: Static icons in the Category frame
Post by: emilio on April 07, 2006, 05:12:38 PM
hola V@no

I´am sorry. I can´t do it, could you help me please?

this is the code of my category_bit.html:

Code: [Select]
table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
<td width="50" rowspan="2" align="center" valign="top">
<a href="{cat_url}"><img src="{template_lang_image_url}/category{cat_id}.gif" border="1"></a></td>
<td align="left" valign="top"><a href="{cat_url}" class="maincat">{cat_name}</a>&nbsp;({num_images})</td>
 </tr>
 <tr>
<td align="left" valign="top">&nbsp;</td>
 </tr>
</table>

thanks

saludos
emilio
Title: Re: Static icons in the Category frame
Post by: V@no on April 07, 2006, 11:56:00 PM
Code: [Select]
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50" rowspan="2" align="center" valign="top">
<?php
$icon 
"folder.gif";
if (
in_array($this->val_cache['cat_id'], array(1,2,3,4)))
{
  
$icon "category".$this->val_cache['cat_id'].".gif";
}
echo 
"<a href=\"".$this->val_cache['cat_url']."\"><img src=\"".$this->val_cache['template_lang_image_url']."/".$icon."\" border=\"1\"></a>";
?>

</td>
<td align="left" valign="top"><a href="{cat_url}" class="maincat">{cat_name}</a>&nbsp;({num_images})</td>
</tr>
<tr>
<td align="left" valign="top">&nbsp;</td>
</tr>
</table>
Title: Re: Static icons in the Category frame
Post by: emilio on April 08, 2006, 12:18:18 AM
hi V@no

I´m sorry, I know that I insist much  :oops:

in my includes/constants.php I have this:

// Allow execution of PHP code in templates
define('EXEC_PHP_CODE', 1);

this is ok.

but when put your code in category_bit.html, I see this:

Parse error: parse error in c:\appserv\www\comprar\includes\template.php(101) : eval()'d code on line 8

saludos
emilio

Title: Re: Static icons in the Category frame
Post by: V@no on April 08, 2006, 12:27:53 AM
fixed now ;)
Title: Re: Static icons in the Category frame
Post by: Kane on October 24, 2006, 02:41:21 AM
Thanks! This is exactly what I needed.
Title: Re: Static icons in the Category frame
Post by: gustav on December 18, 2006, 05:07:09 PM
Vano.... can't you alter your code so, that it just shows the default folder icon if no dedicated icon for the specific category can be found? To avoid the need of filling the array with all the categories that should show a custom icon.....

Quote
Code: [Select]
<?php
$icon 
"folder.gif";
if (
in_array($this->val_cache['cat_id'], array(1,2,3,4)))
{
  
$icon "category".val_cache['cat_id'].".gif";
}
echo 
"<a href=\"".$this->val_cache['cat_url']."\"><img src=\"".$this->val_cache['template_lang_image_url']."/".$icon."\" border=\"1\"></a>";
?>
Title: Re: Static icons in the Category frame
Post by: mohrth on January 08, 2007, 05:17:09 PM
Hi! V@no

Kann man den Code so umstellen das nicht das Bild UND das folder.gif kommt.
Wenn ich die Kategorien ausblenden will, bei denen das folder.gif NICHT erscheinen soll, dann kommt das von mir erstellte Bild doppelt!

Hier ist mein Code im Moment:

Code: [Select]
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
<td width="70" rowspan="2" align="center" valign="top">

<?php
$icon 
"folder.gif";
if (
in_array($this->val_cache['cat_id'], array()))
{
  
$icon "category".$this->val_cache['cat_id'].".gif";
}
echo 
"<a href=\"".$this->val_cache['cat_url']."\"><img src=\"".$this->val_cache['template_image_url']."/".$icon."\" border=\"1\"></a>";
?>


<a href="{cat_url}"><img src="{template_image_url}/category{cat_id}.gif" border="1"></a></td>
<td align="left" valign="top"><a href="{cat_url}" class="maincat">{cat_name}</a>&nbsp;({num_images})</td>
 <td>
{if cat_is_new}<sup class="new">{lang_new}</sup>{endif cat_is_new}
  </td>
  </tr>
  <tr>
<td align="left" valign="top">{if cat_description}<span class="smalltext">{cat_description}</span><br />{endif cat_description}</td>
  </tr>
</table>

{if sub_cats}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
<td width="50" align="center" valign="top"><img src="{template_image_url}/joinbottom.gif"></td>
<td align="left" valign="top">{sub_cats}</td>
  </tr>
</table>
{endif sub_cats}

Hier ein Bild:
Title: Re: Static icons in the Category frame
Post by: mohrth on January 09, 2007, 02:08:29 PM
Hi! V@no

Kann man den Code so umstellen das nicht das Bild UND das folder.gif kommt.
Wenn ich die Kategorien ausblenden will, bei denen das folder.gif NICHT erscheinen soll, dann kommt das von mir erstellte Bild doppelt!


Ok...hab das Problem selber gelöst....Hab den Code von ersten Autor noch mitübernommen => deswegen doppelt.
Code: [Select]
<a href="{cat_url}"><img src="{template_image_url}/category{cat_id}.gif" border="1"></a>Wenn der ausgeklammert oder gelöscht wird und in in den "()))" die category ID reingeschrieben wird die ein selber erstelltes Bild besitzen,
dann funktioniert das alles wunderbar!

Hier mein aktueller Code:
Code: [Select]
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
<td width="70" rowspan="2" align="center" valign="top">


<?php
$icon 
"folder.gif";
if (
in_array($this->val_cache['cat_id'], array(22,23,24,28,25,4,45,48,69,74,75,85,98,99,103,112,6,7,8,55,92,93,90,95,96,100,94,101,11,76,77,78,79,80,12,13,14,15,56,
100,106,110,109,17,18,19,104,105,32,34,35,40,89,27,26,29,46,49,51,82,87,91,102,111,113,43,44,63,72,1,5,10,16,30,37,53,70,41,71)))
{
  
$icon "category".$this->val_cache['cat_id'].".gif";
}
echo 
"<a href=\"".$this->val_cache['cat_url']."\"><img src=\"".$this->val_cache['template_image_url']."/".$icon."\" border=\"1\"></a>";
?>


</td>

<td align="left" valign="top"><a href="{cat_url}" class="maincat">{cat_name}</a>&nbsp;({num_images})</td>
 
<td>
{if cat_is_new}<sup class="new">{lang_new}</sup>{endif cat_is_new}
  </td>

  </tr>
  <tr>
<td align="left" valign="top">{if cat_description}<span class="smalltext">{cat_description}</span><br />{endif cat_description}</td>
</tr>
</table>

{if sub_cats}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
<td width="50" align="center" valign="top"><img src="{template_image_url}/joinbottom.gif"></td>
<td align="left" valign="top">{sub_cats}</td>
  </tr>
</table>
{endif sub_cats}
Title: Re: Static icons in the Category frame
Post by: thejflo on October 28, 2008, 03:07:18 AM
How do I do it, that it will only show 1 Catimage not category1, category2, category3, categoryn ?

EDIT:
Thx, I figured it myself out!

Thx, Fuz

I have that problem but I couldn't figure it out. Can someone show me how I all the rest of category2, category3, etc. to show?

edit. heh, figured it out myself.

thanks.
Title: Re: Static icons in the Category frame
Post by: camera on October 29, 2008, 04:29:56 PM
Great mod. It works as expected.