Jump to content

Edit Language field through API


zaib
 Share

Recommended Posts

I've a json file, and from json file I'm creating some dynamic pages, problem is how i can edit language field or how to add new filed through API

I'm doing like this

<?php
  $string = file_get_contents('incl/codes.json');
  $json_a = json_decode($string, true);
  $arabic = $languages->get("Arabic");
  $page->of(false);
  foreach($json_a as $code){
      $p = new Page(); // create new page object
      $p->template = 'city_code'; // set template
      $p->parent = wire('pages')->get('/master_data/city_codes'); // set the parent
      $p->name = $code["CITY_CODE"]; // give it a name used in the url for the page
      $p->title = $code["CITY_CODE"]; // set page title (not neccessary but recommended)
      $p->title->setLanguageValue($arabic, $code["CITY_AR"]);
      $p->save();

  }
?>

 

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