favicon enhanced

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
eh
Forum Members
Forum Members
Posts: 29
Joined: Sun Oct 07, 2007 1:19 pm

favicon enhanced

Post by eh »

Hi

There's the UDT provided by Christophe Lambrechts to display a favicon in the browser. See here for the details: http://wiki.cmsmadesimple.org/index.php/Share_your_tags_here#favicon.

If you search the forum for "favicon" you'll notice that there can be troubles with the location of the favicon. One solution to this issue is to provide the full URL to the favicon, i.e.http://mycms/myimages/favicon.ico

Here's the code snippet how I extended Christophe's UDT to prepend the icon name with the http-part:

Code: Select all

f(isset($params['static']))

   global $gCms;

   $favicon_path = $gCms->config['root_url']  . "/"  . $params['static'];

   echo '<link rel="shortcut icon" href="'.$favicon_path.'" type="image/x-icon" /link>'."\n"; 

  ...

In your template call the UDT like this:

Code: Select all

{favicon static="myimages/favicon.ico"}
whereby "myimages" is located below the root folder of your CMSMS installation. Make sure that Apache or any other web server can access the icon by manually entering the full URL in a browser for test:

http://mycms/myimages/favicon.ico

This should work for all browsers (don't know if there are any performance penalties, though).
Elise
Forum Members
Forum Members
Posts: 24
Joined: Sun Jan 03, 2010 10:13 pm

Re: favicon enhanced

Post by Elise »

This is nice, thank you!
Felix
Forum Members
Forum Members
Posts: 54
Joined: Wed Oct 31, 2007 11:32 pm
Location: Melbourne, Australia

Re: favicon enhanced

Post by Felix »

Thank you, eh.

I searched all over the place for ages looking for a way to get the favicon to work.  Your UDT worked a treat!

Cheers,

Felix
faglork

Re: favicon enhanced

Post by faglork »

Maybe I am dense ... but why use an UDT?

Why not simply put the favicon code in the header?

Code: Select all

<link rel="icon" href="/url/to/favicon.ico" type="image/gif" />
Do I miss something?

Cheers,
Alex
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am
Location: Berlin

Re: favicon enhanced

Post by nicmare »

or why dont you do it like me?

Code: Select all

<link rel="shortcut icon" type="image/x-icon" href="{root_url}/favicon.ico" />
or do i miss something??
Post Reply

Return to “Tips and Tricks”