• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC

Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Bulletproof favicon on multisite server
PostPosted: Sun Jul 22, 2012 10:42 am 
Forum Members
Forum Members

Joined: Fri Dec 10, 2010 5:35 pm
Posts: 27
Do you have a multi site server && PRETTY_URLS && Favicon on different location than CMSMS index.php

In my case I have
  • favicon.ico on uploads/misc directory
  • Test on WAMP server (multisite server)
  • Deploy on a CPanel shared hosted for only one site per account
  • Pretty_URLS Active on both TEST and PRODUCTION
  • Some sites need flat pretty_urls some sites don't
  • Use the favicon UDT

That's a perfect recipe for favicon mess


If you use relative paths over non flat pretty_urls you will have the path to favicon relative to current content level on content tree
If you use flat pretty_urls your client might want tomorrow to change to non-flat pretty_urls.

The solution might be to use absolute path for favicon, that works ok on single site shared host, but if you try to use absolute path on multisite server you may end up with absolute paths pointing to your /home directory.

So, sometimes you may have favicon working on start page and not working on rest of site, or not working at all. Or favicon working on production site, but not on test server.
You can change the paths to favicon on test site, and then rearrange them to work on production, but if you use more than a couple of templates it might become a PITA on the long run.

The solution is to use the {root_url} tag for creating dynamic absolute paths (sounds weird uh. Always tought dynamic and absolute are mutually excluding) inside the {favicon} udt

Since you can't call to {root_url} inside the {favicon} udt. And like Calguy says "Smarty is smart but not that smart" (talking about nested smarty tags on another thread in this forum) I took his approach and got to this:

{capture assign='root_url'} {root_url}{/capture}
{favicon static="$root_url/uploads/misc/favicon.ico"}

the first line, takes the value from {root_url} tag, converts it to an smarty variable and passes it to the second line and there it is. Now you have dinamically created an absolute url to your site favicon.

the result will be this line generated on your html

<link rel="shortcut icon" href=" http://yourserver/CMSMS_ROOT/uploads/misc/waterland.ico" type="image/x-icon" />

Correct every time

Hope this is helpful and avoid some headaches to some not so experienced webmasters (like myself).


Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting