More in this section

Forums / General Discussions / NewsRotator and different languages.

NewsRotator and different languages.

3 posts, 0 answered
  1. F
    F avatar
    34 posts
    15 Mar 2011
    31 May 2011
    Link to this post

    I'm using the newsrotator on a bilingual website (FR/EN) with Sitefinity 4.1 SP1. It works fine and retrieves and displays news correctly in the website's primary language (FR).
    I created a couple of news, and created one in both languages, as a test (giving the news the same title in both languages to bind it to the thumbnail).

    The problem is when i switch in engligh, the newsrotator doesn't display any news.

    In debug mode, I found where part of the problem might be :

    this.RadRotator1.DataSource = App.WorkWith().NewsItems().Where(n => n.Status == ContentLifecycleStatus.Live).Get().Take(this.NewsLimit).ToList().Join(
                                               App.WorkWith().Images().Get().Where(i => i.Parent.Title == "Thumbnails" && i.Status == ContentLifecycleStatus.Live),
                                               item => item.Title.Value,
                                               image => image.Title.Value,
                                               (item, image) => new { NewsItem = item, NewsImage = image });
               //this.RadRotator1.DataSource = App.WorkWith().NewsItems().Where(n => n.Status == ContentLifecycleStatus.Live).Get().Take(this.NewsLimit).ToList();
               this.RadRotator1.ItemDataBound += new RadRotatorEventHandler(this.RadRotator1_ItemDataBound);

    In FR as well as in EN, the datasource retrieves the same number of news. 
    The problem appears at the DataBind(), which is done properly in FR, and not in EN for some reason.

    Is there anything wrong with the request  that makes it not work in languages other than the primary language?

    Thank you,
  2. Lyubomir Dokov
    Lyubomir Dokov avatar
    43 posts
    06 Jun 2017
    03 Jun 2011
    Link to this post

    Hi F,

    The NewsRotator from the SDK samples is not implemented to work with multiple languages. However, it should be easy to adjust it.

    First, you need to filter the NewsItems by the current language. This is not done in the code and that is why you get the same number of NewsItems in both languages. This is how it should be done:

    this part:

    this.RadRotator1.DataSource = App.WorkWith().NewsItems().Where(n => n.Status == ContentLifecycleStatus.Live).Get().Take(this.NewsLimit).ToList().Join(.....
    should become like this:

    this.RadRotator1.DataSource = App.WorkWith().NewsItems().Where(n => n.Status == ContentLifecycleStatus.Live).Get().ToList().Where(item => item.AvailableCultures.Contains(CultureInfo.CurrentUICulture)).Take(this.NewsLimit).Join(....
    The Join(...) part must remain the same. This should filter the NewsItems by the current language.

    I think this should be enough, but you wrote that you do not see any news in the English version, so I guess there is some other problem. Do you see anything at all in the NewsRotator when you are in English, some images, etc.? Or nothing at all? Maybe you could set a breakpoint in theRadRotator1_ItemDataBound method and see if it gets called as expected (once for each news item available in the current language).

    Lyubomir Dokov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. F
    F avatar
    34 posts
    15 Mar 2011
    13 Jun 2011
    Link to this post
    Thank you for your help. I'll try that as soon as I get a chance.
3 posts, 0 answered