I have a menu container that contains link items. The menu container is just a container so it does not need to have separate versions in all the active site languages. More specifically, it will always only contain a version in english. The childitems however need to have separate versions in the active languages and there should be no language fallback if an item does not have a version in a language.
The code:
var mainMenuContainer = menuContainer.Children.FirstOrDefault(ch => ch.Name == MAINMENU_ITEMNAME);
So the mainMenuContainer will have the english language.
Then I do:
var mainNavItems = mainMenuContainer.Children.Where(m => m.TemplateID == Constants.LinkItemTemplateId);
How could I enforce that this call only returns child items that have a version in the context language? Maybe I could do something like
foreach (var language in item.Languages)
{
var langSpecificItem = MasterDb.GetItem(item.ID, language);
if (langSpecificItem.HasVersion())
{
}
}
but this seems not to be a terribly efficient way. I see that I could also check the IsFallback property of each item, but that seems not to be very elegant.