Retrieve News articles of particular language

Posted by Community Admin on 04-Aug-2018 09:39

Retrieve News articles of particular language

All Replies

Posted by Community Admin on 02-Jan-2012 00:00

Plse help us to retrieve all Published News articles in particular Language.
Ex: We have 4 languages (en, de, fr, it).
When Current language is de, I need only articles published in de..
Thanks..

Posted by Community Admin on 03-Jan-2012 00:00

Hi,

 In the database, there is actually only one news item entry for all available cultures. When you add a new culture, for each LString column in that table, a new column with the localization is added. So, when you get the items, you get only one for each localization. However, you can get the different localized properties for the different cultures. Here's a sample code on how to do that (gets the Content of the first NewsItem in the collection):

NewsManager mng = NewsManager.GetManager();
            var news = mng.GetNewsItems().First().Content["en-US"];

Kind regards,
Svetoslav Petsov
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

Posted by Community Admin on 04-Jan-2012 00:00

NewsManager mng = NewsManager.GetManager();
var news = mng.GetNewsItems().First().Content["en-US"];

The above code displays content by considering a single News article.

We need all news articles  content or data in corresponding languages.
Which means while retrieving itself , we want to get news articles wrt respective languages.
Is tat possible with Sitefinity API.

Ex: If we have 15 news articles published in all the languages (en,de,it and fr),we need to display news content, title,etc wrt each language.

Posted by Community Admin on 04-Jan-2012 00:00

Hello,

 What you can do in such case is just get ALL of the news articles in one collection, then perform a foreach loop and for each item get the respective properties that you need, in the language that you need, just like I've shown you in the example (for every LString property, you can just type item.Property[culture] and get it for the respective culture).

All the best,
Svetoslav Petsov
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

Posted by Community Admin on 06-Jan-2012 00:00

Looping thru all News Item and taking Current cultures News articles worked.
Thanks
But before considering News item, it should be verified whether it is PublishedTranslations contains current culture. If it is published in Current culture, then only tat News Item has to be considered.

Posted by Community Admin on 06-Jan-2012 00:00

Hello,

 I'm I was able to guide you in the right direction to solve the problem. You are correct about the check - do you need any help with that? Do not hesitate to contact me if you do.

Regards,
Svetoslav Petsov
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

This thread is closed