Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: [MINI ADDON] - Add favorite icon to your site  (Read 6228 times)

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
[MINI ADDON] - Add favorite icon to your site
« on: December 12, 2007, 03:28:35 pm »

Create your favorite icone and save it to favicon.ico and copy to your images folder

In index.php add this line, change red text with your real folder.
Find
Quote
<meta name="generator" content="sNews 1.6" />
Put after that
Quote
<link rel="shortcut icon" type="icon" href="images/favicon.ico" />
Logged
Need a Job on Europe. Linkdin - Facebook / Group

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #1 on: January 09, 2008, 09:03:58 pm »

@ Rui... I've used favicons before with sNews 1.4... using exactly the same string.
I am trying to use it today on a 1.6 project. I am running on my Localhost (Xampp-XP) as well as two other 1.4 projects that use favicons.
I notice that the favicon.ico image displays in the browser bar (IE7) when the sites are on their home pages... but when I click and display any other page... the favicon gets replaced with the xampp favicon image. Have you experienced this with your site(s) - online or on localhost?
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #2 on: January 09, 2008, 09:18:29 pm »

Simple fix:

Change
Quote from: Rui Mendes
<link rel="shortcut icon" type="icon" href="images/favicon.ico" />

To:
Quote
<link rel="shortcut icon" type="icon" href="'.db('website').'/images/favicon.ico" />

Also, some browsers by default like to look in the domain root for favicon.whatever*, so it could be a good idea to put your favicon on the root instead of in images. But that's optional.

*) Yes, with Firefox, Safari, Opera and a few other browsers including IE7 you can use any accepted image format for your favicon -- like favicon.gif, favicon.png or favicon.jpg -- there was even a time when Firefox/Camino (Mac) supported animated favicon gifs, but I don't they do anymore... ;)
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #3 on: January 09, 2008, 09:44:03 pm »

Simple fix:
Quote
<link rel="shortcut icon" type="icon" href="'.db('website').'/images/favicon.ico" />
Yes... we'd expect that to work... and I tried it... but it's still the same... only displaying on home. Perhaps its a localhost 'condition'... I just checked a couple of my online domains (back up now)... same thing. Perhaps the above doesn't work as the .db('website') value may not be active unless it's enclosed in php-tags?
« Last Edit: January 09, 2008, 10:06:59 pm by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #4 on: January 10, 2008, 12:34:33 am »

You can add alternative in title function,

Quote
// TITLE
function title() {
   echo '<link rel="shortcut icon" type="icon" href="'.db('website').'favicon.ico"/>';
   echo '<base href="'.db('website').'" />';

I see works in FF and safari, as I know IE7 works, but not IE5/6.

For IE5/6 Microsoft give this solution
Quote
<script>
<!--
if ((navigator.appVersion.indexOf("MSIE") > 0)
  && (parseInt(navigator.appVersion) >= 4)) {
    var sText = "<u><span style='color:blue;cursor:hand;'";
    sText += "onclick='window.external.AddFavorite(location.href,";
    sText += "document.title);'>Add this page to your favorites</span></u>";
    document.write(sText);
}
//-->
</script>
Logged
Need a Job on Europe. Linkdin - Facebook / Group

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #5 on: January 10, 2008, 12:46:07 am »

@Doug -- Sorry, I misread. Thought for some reason that the mod applied to snews.php. My mistake.

If you have the link rel statement in index.php you could do
Quote
<link rel="shortcut icon" type="icon" href="<?php echo s('website'); ?>images/favicon.ico" />

However, if you haven't removed the base href line in function title (in snews.php), the favicon location should be picked up without having to do extra ('website') call, either in index.php or snews.php, so something else is probably afoot, since the base href sets the site root -- regardless if local or not. At least, it should. In MAMP, as a comparison, the only time its own favicon is read is when it can't locate the favicon you specify. Hmm... it could be a base href problem... but then you'd get all sorts of weirdness, not just a missing favicon, so that doesn't really make sense either.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #6 on: January 10, 2008, 01:54:56 am »

I know... it SHOULD work just by putting the standard line - <link rel="shortcut icon" href="images/favicon.ico" /> in the <head> of index.php... and it does (as previously noted) but only on the Home page. However, this work-around is displaying it on all pages just perfectly... by putting the string in a php function and calling it into the <head> with the function-name.

Quote
// the function in favicon.php
function favico() { echo '<link rel="shortcut icon" type="icon" href="'.db('website').'/images/favicon.ico" />'; }

// and the function-name in index.php
<?php favico(); ?>
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

henrich

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 381
  • Passion for quality and excellence!
    • My personal blog and portofolio
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #7 on: February 27, 2008, 03:12:52 am »

What is hte purpose of the next line:

Code: [Select]
<meta name="generator" content="sNews 1.6" />
 ???
Logged
By(e) Henrich :)
------------------------------
IT related blog

Nicu Alecu

  • Full Member
  • ***
  • Karma: 12
  • Posts: 224
    • BLUEBYTE.ro // IT consultant
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #8 on: February 27, 2008, 11:21:36 am »

I somehow missed this thread.
Key, wouldn't it be a lot simpler to place the favicon.ico in the root, along wih the snew.php & stuff and be done with it? I know that's what I do and it always works (unless I completely forget about favicons, of course).

@Henrich ... there's no special purpose, I think; it just helps to identify sites that run on sNews.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #9 on: February 27, 2008, 11:24:38 pm »

Quote from: Nicu Alecu
I somehow missed this thread.
Key, wouldn't it be a lot simpler to place the favicon.ico in the root, along wih the snew.php & stuff and be done with it? I know that's what I do and it always works (unless I completely forget about favicons, of course).

You may well be right. I've noticed a problem with my approach... it works fine on localhost but it's not working online. I have favicons working on a few sNews 1.4 sites (online) just fine... I'll go back into them and see how I have them working there.

Quote from: henrich
What is the purpose of the next line - <meta name="generator" content="sNews 1.6" />
 ???

It's just a hard-coded meta tag string that identifies your website when it's picked up by search engines. It is as Nicu Alecu noted... but you are free to change (customize) it to a short 2 or 3 word description of your site.
« Last Edit: February 27, 2008, 11:28:36 pm by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Greyh0und

  • Newbie
  • *
  • Karma: 0
  • Posts: 1
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #10 on: November 16, 2009, 12:08:11 pm »

Since this was the first thread I found on searching 'favicon'
This is what made the favicon work for me:

<link rel="icon" type="image/x-icon" href="favicon.ico">

just place the favicon in the main map :)
really, why all the trouble for using a favicon?
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MINI ADDON] - Add favorite icon to your site
« Reply #11 on: November 16, 2009, 05:26:11 pm »

Greyh0und -- As noted in some posts above, the favicon may work on the home page with that approach but (depending on your system/browser) it might fail on lower level pages (e.g "domain.com/category/article/"). It's basically to force your favicon to appear on all pages produced by the system. Generally speaking though, yes, absolutely enough.
Logged

last_hopes

  • Newbie
  • *
  • Karma: 0
  • Posts: 1
  • last_hopes
MINI ADDON Add favorite icon to your site
« Reply #12 on: December 07, 2009, 07:53:57 pm »

ok , im waiting . Thanks for your work .
But i reckon that CSDC official site must be better
Logged
last_hopes