November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi, that is very simple but please post your detail code here so we can figure out what's wrong!
Basically, it should be:
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
var loaderOptions = new LoaderOptions { LanguageLoaderOption.MasterLanguage() };
contentLoader.TryGet<IContent>(contentLink.ToReferenceWithoutVersion(), loaderOptions, out var masterVersion);
or
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
var loaderOptions = new LoaderOptions { LanguageLoaderOption.Specific("en") };
contentLoader.TryGet<IContent>(contentLink.ToReferenceWithoutVersion(), loaderOptions, out var masterVersion);
Thanks for the input. This is Working.
The difference was that I was not using .ToReferenceWithoutVersion().
For reference below was my code
if (args.Content is CategorizablePageWithImage categorizable)
{
if (!categorizable.IsMasterLanguageBranch)
{
_contentLoader.TryGet<CategorizablePageWithImage>(categorizable.ContentLink, new LoaderOptions { LanguageLoaderOption.MasterLanguage() }, out var masterLanguageContent);
var expiryDate = (masterLanguageContent as IVersionable).StopPublish;
categorizable.StopPublish = expiryDate;
}
}
I have multiple languages enabled in our CMS application. We expect users to enter the expiration date on the content when initially published in master language (english). When the pages are translated, I am trying to tap into the Save event to apply the expiration date from the master language content to the new language.
I tried using content loader with new LoaderOptions() { LanguageLoaderOption.Specific(CultureInfo.GetCultureInfo("en")) } and no matter what I use, specific/fallback/fallbackwihtmaster I am always presented the content in the current language branch and not from the master.
Is there something I am doing wrong here ?