Jump to content

batch change value per language in FieldtypeTextareas fields


bbeer
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...