Retrieve News articles of particular language
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..
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"
];
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.
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,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.
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,