NewsRotator and different languages.
Hello,
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);
this.RadRotator1.DataBind();
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(.....
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(....
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).
Thank you for your help. I'll try that as soon as I get a chance.