Jump to content

batch change value per language in FieldtypeTextareas fields


Recommended Posts

Posted

Hi all

we like to to change the content of some fields inside a FieldtypeTextareas field per API for several pages. her an example for one page.

// set language

wire("user")->language = 1014;
// read language
$en = wire("languages")->get('en');

// list all products form this template is ok
foreach(wire('pages')->find("template=product,sort=prod_calc_capacity,include=hidden") as $p){

// for one product
if((string)$p == "1798"){
// read value from multifield, is ok
$fe = $p->prod_features_multi->prod_rating_operating_voltage;
// output value, is ok
echo "$fe<br />";
// set new value, value not set and why? nok
$p->setLanguageValue($en, 'prod_rating_operating_voltage', 'test');
}
}

your help is much appreciated.

Posted

I am no multi language expert, but i think you need this:

$p->prod_rating_operating_voltage->setLanguageValue($en, 'test');
Posted

Hi adrain

nope that does not work. get an Fatal error: Call to a member function setLanguageValue() on a non-objec

Posted (edited)

Oh I see - you are using a textareas field - sorry, I read textarea, not the plural.

What about:

$p->prod_features_multi->prod_rating_operating_voltage->setLanguageValue($en, 'test');

BTW, I am sure it works fine, but why:

if((string)$p == "1798"){

and not:

if($p->id == 1798){

EDIT: Are you using the new multilanguage version of the textareas fieldtype?

Also, maybe this question should be posted in the support thread for Profields - that way it will get Ryan's attention for sure.

Edited by adrian
Posted

no it does not work, same error. 

Your BTW has nothing directly to do with the problem, but we changed it.

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