Page 1 of 3
Category Icons / Images
Posted: Wed Mar 07, 2007 7:40 pm
by NimNim
When settings up my blog I assigned certain pictures to each category.
I've just noticed that those pictures never seem to be used.
Where / when should they be displayed?
How do I fix this?
Thank you,
Nim
Re: Category Icons / Images
Posted: Wed Mar 07, 2007 7:49 pm
by garvinhicking
Hi!
Usually if you post an entry to a category, viewing that category on the frontpage should contain an category icon.
This depends on the template you are using, some do not use it. The Serendipity 3.0 default theme displays it in the info box, for example.
Best regards,
Garvin
Posted: Wed Mar 07, 2007 7:52 pm
by NimNim
I'm using the Competition template. It doesn't do that, so I guess it doesn't utilise that facility

Ho hum.
Thank you.
Nim
Posted: Wed Mar 07, 2007 7:54 pm
by NimNim
However, in the category menu, each category has this icon in front of it:
Do you know if there is a file where I can edit the category menu, instructing it to use my icons instead of that red square?
If not, don't worry.
Thank you,
Nim
Posted: Wed Mar 07, 2007 10:06 pm
by garvinhicking
Hi!
Sadly I don't know the competition that well - but you might want to take the default/entries.tpl file and compare it to the one of the competition theme. Look for the string 'category_icon'!
Do you know if there is a file where I can edit the category menu, instructing it to use my icons instead of that red square?
You can configure your categories plugin to enable smarty templating. Then you can copy the 'plugin_categories.tpl' smarty file to your theme directory and customize it with category icons!
HTH,
Garvin
Posted: Thu Mar 08, 2007 1:11 am
by d_cee
Hi
Category icons are disabled in my competition template. If you'd like to enable them look for the following code in the entries.tpl
Code: Select all
<!--
<span class="serendipity_entryIcon">
{foreach from=$entry.categories item="entry_category"}
{if $entry_category.category_icon}
<a href="{$entry_category.category_link}"><img class="serendipity_entryIcon" title="{$entry_category.category_name|@escape}{$entry_category.category_description|@emptyPrefix}" alt="{$entry_category.category_name|@escape}" src="{$entry_category.category_icon}" /></a>
{/if}
{/foreach}
</span>
-->
and remove the '
<!--' from the start and the '
-->' from the end.
To get the category list plugin to use your category icon I think you just turn on the smarty option in the categories plugin config. If you want to style the plugin you'll need to copy plugin_categories.tpl from the default template folder into the competition folder.
HTH
Dave
Posted: Thu Mar 08, 2007 2:19 pm
by NimNim
Ooo, thank you, that worked!!!!
Now I'll try the icons in the list
Nim
Posted: Thu Mar 08, 2007 2:29 pm
by NimNim
Ok, I request babysteps for the NimNim (ie me).
I'm looking here: G:\My Webs\1&1\Blog\Serendipity\serendipity\plugins ... is that the wrong folder in which to find the categories plugin config?
I'm going to try that to see what it does, before I try anything with plugin_categories.tpl.
Sorry to be a bother.
Nim
Posted: Thu Mar 08, 2007 3:54 pm
by d_cee
Hi
you just need to copy the plugin_categories.tpl from the default template folder into the competition folder. Enable the smarty option in the categories plugin configuration and then style away!
Dave
Posted: Thu Mar 08, 2007 4:36 pm
by NimNim
Ok, I've done that.
Edit away heheheh ... I don't know PHP, so reading it that file I'm guessing it what it all means.
Would I be right that this is the bit that calls the image to the category menu:
{if !empty($category_image)}
<a class="serendipity_xml_icon" href="{$plugin_category.feedCategoryURL}"><img src="{$category_image}" alt="XML" style="border: 0px" /></a>
{/if}
If so, then I need to know how to edit that part. I need to specify each category name, and call the appropriate image. How do I do that???
Nim
Posted: Fri Mar 09, 2007 9:56 am
by garvinhicking
Hi!
You can enter this code:
Code: Select all
{if $plugin_category.category_name == 'Media'}
<img src="/path/to/your/image.gif" alt="Cateogry icon" style="border: 0px" />
{else if $plugin_category.category_name == 'Private'}
<img src="/path/to/your/image2.gif" alt="Cateogry icon" style="border: 0px" />
{else if $plugin_category.category_name == 'Public'}
<img src="/path/to/your/image3.gif" alt="Cateogry icon" style="border: 0px" />
{/if}
Regards,
Garvin
Posted: Fri Mar 09, 2007 6:40 pm
by NimNim
Hi again,
I've edited the code you gave me, to this:
{if $plugin_category.category_name == 'Books'}
<img src="/Serendipity/templates/competition/img/Books.gif" alt="Books" style="border: 0px" />
{else if $plugin_category.category_name == 'CFS'}
<img src="/Serendipity/templates/competition/img/CFS.gif" alt="CFS" style="border: 0px" />
{else if $plugin_category.category_name == 'Depression'}
<img src="/Serendipity/templates/competition/img/Depression.gif" alt="Depression" style="border: 0px" />
{else if $plugin_category.category_name == 'Dreams'}
<img src="/Serendipity/templates/competition/img/Dreams.gif" alt="Dreams" style="border: 0px" />
{else if $plugin_category.category_name == 'General'}
<img src="/Serendipity/templates/competition/img/General.gif" alt="General" style="border: 0px" />
{else if $plugin_category.category_name == 'Pets'}
<img src="/Serendipity/templates/competition/img/Pets.gif" alt="Pets" style="border: 0px" />
{else if $plugin_category.category_name == 'Work'}
<img src="/Serendipity/templates/competition/img/Work.gif" alt="Work" style="border: 0px" />
{/if}
I wasn't quite sure where to put it, so I tried it in various different places, within plugin_categories.tpl .. but each time it gives me this error:
Fatal error: Smarty error: [in file:/kunden/homepages/21/d98723615/htdocs/Serendipity/templates/competition/plugin_categories.tpl line 21]: syntax error: unexpected {else} (Smarty_Compiler.class.php, line 468) in /homepages/21/d98723615/htdocs/Serendipity/bundled-libs/Smarty/libs/Smarty.class.php on line 1088
Any idea what I might be doing wrong?
Nim
Posted: Sun Mar 11, 2007 4:00 am
by judebert
What's on and around line 21 of plugin_categories.tpl?
Posted: Sun Mar 11, 2007 1:41 pm
by garvinhicking
Hi!
Upps. You need to use "elseif" instead of "else if".
Regards,
Garvin
Posted: Sun Mar 11, 2007 9:31 pm
by NimNim
Ah. Thanks ... NOW my husband says 'Oh yeah .. that makes sense!!!!'
Can you have a quick look please:
http://www.sylviathornhill.co.uk/Serendipity/index.php
The pictures are coming up as red squares, which obviously means I have the path wrong (they're in my template images folder); I'm pretty sure I can figure that part out.
The other image is still there though .. xml.gif image. Any idea how to get rid of it altogether?
Thanks
Nim