Different favicons per site in Kentico

   —   
This article will describe how you can use different favicons for multiple web sites when using portal engine templates.
Since the DocumentBase.cs file was moved to an assembly in version 4.0 it is harder to override the favicons handling. But you can eventually add custom literal control into HEAD section in CMSPages/PortalTemplate.aspx file, for example:

<asp:Literal runat="server" ID="ltlFavicon" />

and in code-behind complete and add appropriate HTML code for favicon into Text property of this literal in according to value CMS.CMSHelper.CMSContext.CurrentSite.SiteName property (e.g. in OnPreRender event):

if (CMS.CMSHelper.CMSContext.CurrentSite.SiteName == "<siteName>")
{

this.ltlFavicon.Text = "<LINK REL=\"SHORTCUT ICON\" HREF=\"http://www.domain.com/favicon.ico\">";
}
else
{

this.ltlFavicon.Text = "<LINK REL=\"SHORTCUT ICON\" HREF=\"~/favicon.ico\">";
}

You need to change the site name (marked bold) and in italics are shown possible ways of specifying the path to the favicon file.


See also:

Applies to: Kentico CMS 4.0
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.