Displaying only flags of other cultures, not the current culture flag

   —   
LanguageSelectionWithFlags web part is suitable for multilingual web site navigation. It basically allows you to switch between language versions of your web site and it shows all of the available languages to switch between. However, there are some situations in which you don’t want to show actual culture version within this web part.
So, if you are not for some reason satisfied with pre-defined behavior of this web part, you are free to modify it. What you need to do is to follow steps below:

1.) Please open your ~\CMSWebParts\General\languageselectionwithflags.ascx.cs file. Find line about 167. There should be following code:

foreach (DataRow dr in ds.Tables[0].Rows)
{
   // If exists flag icon file in actual app theme image folder, use it
   if (System.IO.Directory.Exists(this.Server.MapPath("/App_Themes/" + this.Page.Theme + "/Images/Flags/")))
{



Add following code:

foreach (DataRow dr in ds.Tables[0].Rows)
{

if (CMS.CMSHelper.CMSContext.CurrentDocument.DocumentCulture.ToLower().ToString() != dr["CultureCode"].ToString().ToLower() )
{
   // If exists flag icon file in actual app theme image folder, use it
   if (System.IO.Directory.Exists(this.Server.MapPath("/App_Themes/" + this.Page.Theme + "/Images/Flags/")))
   {


2.) Please do not forget to close the IF statement with “}” in appropriate place.

Please note, that any custom changes/modifications to Kentico CMS pre-defined web parts will be overwritten when performing upgrade procedure of your current Kentico CMS version. You might find therefore, useful cloning web part tool to clone your LanguageSelectionWithFlags web part and modify its clone and not the original one.



See also:

Applies to: Kentico CMS 3.x
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.