Fun with Favicons

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
User avatar
RobA
Regular
Posts: 317
Joined: Wed Apr 27, 2005 5:11 pm
Contact:

Fun with Favicons

Post by RobA » Fri Oct 28, 2005 3:39 pm

I discovered a fun little trick with Favicons and smarty templating...

If you can't provide your own favicon cause you don't control your root directory, add the following to your index.tpl in the HEAD code:

Code: Select all

<link rel="shortcut icon" type="image/x-icon" href="/uploads/myfavicon.gif" />
<link rel="icon" type="image/x-icon" href="/uploads/myfavicon.gif" />


and replace the "uploads/myfavicon.gif" with the relative URL of whatever you want as your favicon!. It can be a real ico file, or a png, gif, or jpeg. Even animated gifs work (and will show up animated). Try to use an image that scales well to 16x16 however...

To get even fancier, if you find the following code in the HEAD section of index.tpl

Code: Select all

{if $entry_id}
    <link rel="pingback" href="{$serendipityBaseURL}comment.php?type=pingback&amp;entry_id={$entry_id}" />
{/if}


and change it to:

Code: Select all

{if $entry_id}
    <link rel="pingback" href="{$serendipityBaseURL}comment.php?type=pingback&amp;entry_id={$entry_id}" />
    {foreach from=$entry.categories item="category"}
      {if $category.category_icon}
        <link rel="shortcut icon" type="image/x-icon" href="{$category.category_icon}" />
        <link rel="icon" type="image/x-icon" href="{$category.category_icon}" />
      {else}
        <link rel="shortcut icon" type="image/x-icon" href="/uploads/myfavicon.gif" />
        <link rel="icon" type="image/x-icon" href="/uploads/myfavicon.gif" />
      {/if}
    {/foreach}
{else}
  <link rel="shortcut icon" type="image/x-icon" href="/uploads/myfavicon.gif" />
  <link rel="icon" type="image/x-icon" href="/uploads/myfavicon.gif" />
{/if}


(substituting "/uploads/myfavicon.gif" as before) then when an individual article is displayed, the favicon will be the category icon, if one is defined!

-Rob A>
* My s9y blog:
* Rob A's (Im)Personal Blog
* http://www.silent9.com/blog

User avatar
Wizard
Regular
Posts: 103
Joined: Sat Aug 13, 2005 7:18 am
Location: Southern California
Contact:

Wha...

Post by Wizard » Sat Oct 29, 2005 2:55 am

Favicons?
Wizard
My WeBlog

ffaat

Post by ffaat » Sat Oct 29, 2005 1:05 pm

The things that show up next to bookmarks/favorites:

Image

-Rob A>

Post Reply