Language - Inherit settings from the parent page - disable programatically



Regarding the language fallback for a page, ( as mentioned here in your user guide ) can I disable it programatically?

My site has 2 languages, en-NZ and en-AU.

I have a scheduled job that adds 'ProductPage' content under a 'CategoryPage'. I need the parent page (CategoryPage) to be in en-AU and this needs to be the fallback language for en-NZ. Product pages created under it need to be available in either Australia (en-AU) or New Zealand (en-NZ), or both.

My problem is that each 'ProductPage' is getting created with language settings marked as 'Inherit settings from the parent page', so products that are not available in en-NZ are allowed to fallback to en-AU... but I don't want this.

Is there a way to prevent a page from inheriting its fallback language (without unticking it in the cms)?

I appreciate any help



Edited, Nov 21, 2019 12:04

Looks like I may have solved this by setting

productPage.MasterLanguage = null;
Nov 21, 2019 12:43
- Nov 21, 2019 13:06
Haha.. you beat me! nice find.

Hey Dan,

Check out MasterLanguage and MasterLanguageBranch in the PageData class which your ProductPage would be inheriting

Edited, Nov 21, 2019 13:06

This kinda worked... but pages that were not published in NZ were 'falling back' to AU.

I was able to prevent the page from 'falling back' by updating:

var languageSpecificProductPage =  _contentRepository.CreateLanguageBranch<ProductPage>(content, new LanguageSelector("en-NZ"));


var languageSpecificProductPage = _contentRepository.CreateLanguageBranch<ProductPage>(content, LanguageSelector.Fallback(preferredLanguageBranch: language.Name, enableMasterLanguageFallback: false));
Nov 22, 2019 3:29
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.