Category Icons / Images

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
NimNim
Regular
Posts: 30
Joined: Fri Feb 23, 2007 4:19 pm
Location: Toilet Land
Contact:

Category Icons / Images

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Category Icons / Images

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
NimNim
Regular
Posts: 30
Joined: Fri Feb 23, 2007 4:19 pm
Location: Toilet Land
Contact:

Post 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
NimNim
Regular
Posts: 30
Joined: Fri Feb 23, 2007 4:19 pm
Location: Toilet Land
Contact:

Post by NimNim »

However, in the category menu, each category has this icon in front of it:
Image

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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post 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
NimNim
Regular
Posts: 30
Joined: Fri Feb 23, 2007 4:19 pm
Location: Toilet Land
Contact:

Post by NimNim »

Ooo, thank you, that worked!!!! :shock:

Now I'll try the icons in the list :)

Nim
NimNim
Regular
Posts: 30
Joined: Fri Feb 23, 2007 4:19 pm
Location: Toilet Land
Contact:

Post 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
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post 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
NimNim
Regular
Posts: 30
Joined: Fri Feb 23, 2007 4:19 pm
Location: Toilet Land
Contact:

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
NimNim
Regular
Posts: 30
Joined: Fri Feb 23, 2007 4:19 pm
Location: Toilet Land
Contact:

Post 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
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

What's on and around line 21 of plugin_categories.tpl?
Judebert
---
Website | Wishlist | PayPal
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Upps. You need to use "elseif" instead of "else if". :-)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
NimNim
Regular
Posts: 30
Joined: Fri Feb 23, 2007 4:19 pm
Location: Toilet Land
Contact:

Post by NimNim »

Ah. Thanks ... NOW my husband says 'Oh yeah .. that makes sense!!!!' :roll:

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
Post Reply