Jump to content

Recommended Posts

Posted

Hi there,

Surfed the Forum, but couldn't find an answer to my problem :-s


I have two languages and want to show a field ONLY when it has a value in the correct language;

For the default language I can create a simple check offcourse ($page->fieldname = '') 

But how about the alternate language (Let's say Dutch 1017)

To make things more complex, I use this in a sub-function so the main variables of PW aren't arround.

Any ideas?

Michiel

Posted

Hi Michiel,

Easiest solution would be to use the latest dev version of ProcessWire.

There's a setting in each text field which is configured as multilang under the "Details" tab:

Language Support / Blank behaviour
What should happen when this field's value is blank?
[ ] Inherit value from default language
[x] Remain Blank

Choose "Remain Blank" should fix your problem.

  • Like 2
Posted

Hey Wanze, thnx for the support :-) Didn't get a notice so I actually forgot to check here #shame...

Good idea, problem is at this stage PW is beeing used by a major company (bank) and don't really want to use a dev-version (how stable it may be)


Any other ones??

Posted

In a subfunction they aren't available? wire("languages") ? Is available everywhere.

But how about the alternate language (Let's say Dutch 1017)

this should maybe work.

$lang = $languages->get("dutch");
$dutch_field = $page->get("fieldname$lang");

or

$lang = $user->language;
$user->language = $languages->get("dutch");
if($page->fieldname) { ... }
$user->language = $lang;
Posted

Wait for 2.4 release, which is pretty soon.

Apeisa, good idea but I need the fix sooner than 2.4 (although there are some really great features in 2.4 that we love :-)

Soma - Thnx that is a great idea that I didn't try yet... Thnx!

  • 2 weeks later...
Posted

2.4 will be released once the dev branch source has sat for a week or so without any necessary fixes or major additions (meaning, it's reached a stable state). I think that's probably soon, but don't want to promise any dates since I'm actively working on the code almost every day. 

  • Like 5
  • 1 month later...
Posted

edit:

well, that was easy :-)

$f = $fields->get("title");
$f->set("langBlankInherit", 1);
$f->save(); 

I'll keep it here, in case someone else searches for the same thing...

Is there an API function to change the language support blank behaviour?

e.g. change the behaviour of dozens of multilang fields via API? (from "show default language" to "blank" or vice versa).

I see in the DB-table "fields" an entry like this: "langBlankInherit":1 (field "data"), when set to remain blank...

(Using dev version 2.3.2)

  • Like 3

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...