Language switch problem at the News page

Topics: Standard packages
Dec 26, 2010 at 2:20 PM


1) Make sure that the news data you have exist in theother language

2) Check that "News Article" page has a call to "NewsDetails" in both languages

Dec 27, 2010 at 10:35 AM

The function "NewsDetails" - is it a part of one of the packages?  Anyway if you see "empty space where News should be" it is either function weren't called or it was called but it didn't work properly.

Try to edit this function and make it output something even if there's no input data. This way we will see whether the problem is with input data or with the function or with the way you're calling it.

Dec 27, 2010 at 5:01 PM

I checked the tutorial - the function keeps NewsID in url, could it be that when you switch the language it redirects to an incorrect url, which is missing some query string parameters? 

Dec 28, 2010 at 10:24 AM
Edited Dec 28, 2010 at 3:48 PM

You need to write an xslt extension that will be copying query string parameters

1) Create an xslt extension (
2) Add the following method


using Composite.Data;


        public static string GetTranslationLink(string culture)
            var cultureInfo = new System.Globalization.CultureInfo(culture, false);

            System.Collections.Specialized.NameValueCollection notUsedQueryParameters;
            var rawUrl = System.Web.HttpContext.Current.Request.RawUrl;
            var pageInfo = PageUrl.Parse(rawUrl, out notUsedQueryParameters);
            if(pageInfo == null) {
               // In function preview there's no url 
               return string.Empty;

            var urlBuilder = new PageUrl(pageInfo.PublicationScope, cultureInfo, pageInfo.PageId, PageUrlType.Published).Build();
            if (urlBuilder == null)
                // It is possible that page doesn't exist/isn't available by public url
                return string.Empty;


            return urlBuilder.ToString();


3) If you're using the "Omnicorp" demosite, edit xslt function Omnicorp.Navigation.Quick, find the <a .. /> tags that inser translation url and edit it:


   <xsl:stylesheet version="1.0" ...>

    <a href="{$alt/@URL}" title="Change language">...</a>




    <xsl:stylesheet version="1.0" xmlns:example="" ...>
    <a href="{example:GetTranslationLink($alt/@Culture)}" title="Change language">



Dec 30, 2010 at 11:12 AM

It's even easier in this case. Edit /App_Code/Composite/Navigation/LanguageSwitcher/Functions.cs

Add method GetTranslationLink(...) {...}


 new XAttribute("URL", match.Attribute("URL").Value)

replace with

new XAttribute("URL", GetTranslationLink(culture.Name))

Jan 3, 2011 at 10:06 AM

@tvn thanks for the input - it would make good sense to have path/query details from the original URL exposed - it's on our task list :-)