Jump to content

Empty language-alternate fields


Falk
 Share

Recommended Posts

Hi folks!

I have a little problem with some language-alternate filefields file and file_en inside a repeaterfield.

Some repeaters only contain geman files, others only contain english files.

Looking at the german version, everything is fine, you see only german files.

But looking at the english version, you see both english and german files because the default value is displayed if file_en is empty.

Is there a way to not display the default value if file_en is empty?

Regards,

Falk

Link to comment
Share on other sites

This behavior is normally the reason to go for language alternate fields. But you can still get the field as normal by calling file_en or even not using language alternate fields. Either way you would need to build the logic to select the appropriate field on your own.

  • Like 1
Link to comment
Share on other sites

  • 8 months later...

Here's some more info:

https://github.com/ryancramerdesign/ProcessWire/issues/1613

ryancramerdesign commented 

Language fields fallback to default when a localized version isn't available. This is one case where you may want to retrieve the localized value programatically.

$value = $page->get('mytablefield' . ($user->language->isDefault() ? '' : '_' . $user->language->name));
  • Like 3
Link to comment
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
 Share

×
×
  • Create New...