Jump to content
dalibor

How to check if field value is empty in non default language

Recommended Posts

Want to check if the value of the field in nondefault lagnugage is empty (making list of transtlated and non traslated pages of websiste), but if I use $page->getLanguageValue(...) it returns the default language value when the field is empty in another language. And I don't want to turn off  'inherit value from default when empty' in fields detail settings. Anybody nows ho to do that? Thanks.

Share this post


Link to post
Share on other sites

It's probably as simple as temporarily disabling this language inheritance for each field only for the request, where you're building the list. 

foreach($multiLangField as $f) {
	$f->langBlankInherit = LanguagesPageFieldValue::langBlankInheritNone;
}

// Check all your fields

// Make sure non of the fields is saved before exiting

 

  • Like 4

Share this post


Link to post
Share on other sites

Great. I use this to trigger 404 by an empty field in a specific language

// 404 trigger --------------------------/
$fields->get(133)->langBlankInherit = 1;
$langTrigger = $page->getLanguageValue($currLang->id, 'body');
if (!$langTrigger) throw new Wire404Exception();

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...