Page 1 of 1

favicon enhanced

Posted: Mon Apr 28, 2008 8:41 pm
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).

Re: favicon enhanced

Posted: Sun May 02, 2010 10:32 am
by Elise
This is nice, thank you!

Re: favicon enhanced

Posted: Thu Jul 08, 2010 10:25 am
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

Re: favicon enhanced

Posted: Thu Jul 08, 2010 1:09 pm
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

Re: favicon enhanced

Posted: Mon Jul 12, 2010 9:56 pm
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??