Jump to content

Saving a Multi Lingual


Christian
 Share

Recommended Posts

I'm in a process of saving a multi lingual site. The problem is, it only save on the default language of the user.  And not the other language.

Code:

 
public function hookSave(HookEvent $event) {
    // GET PAGE DATA
    $page = $event->arguments[0];
 
    // CHECK IF PAGE USE PAGE REVISIONS TEMPLATE 
$children = $page->children("template=pending-revisions");
 
if( count($children) != 0 ) {
 
$p = new Page();
$p->template = 'home';
$p->parent = wire('pages')->get($children[0]->path());
$p->title = 'Sample Revise';
$p->name = 'Sample Revise';
$p->site_meta_description = 'Sample Revise';
$p->site_headline = 'Sample Revise';
$p->site_sub_headline = 'Sample Revise';
$p->body = 'Sample Revise';
 
$p->save(); 
// die();
  }
Link to comment
Share on other sites

Fixed. I just have to add curly braces.

foreach( $page->fields as $field ) {
  if( ! in_array($field->type, $ignore_field_type) ) {
    $field_name = $field->name;
    $revise_page->{$field_name} = $page->get($field->name);
  }
}

I just changed the field name to dynamic so you might just enclosed static field name to curly braces. 

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