Jump to content

Recommended Posts

Posted

Hi, i created a template with PageReference Field on a multilanguage site. I set possbility to create new page directly from the page template, it works. The new entry was create only in default language. After creation i set the other language by editing the entry. When i try to get field on view i don't find entry in other language:

$services = $pages->find("template=service")

It returns all services if i view site in default lanauge, empty if i view site in other language.

If i create the services directly on Tree it works.

What i can do?

Thanks in advance.

Posted

Does it work if you place this hook in site/ready.php?

<?php
// set all languages active automatically
$wire->addHookAfter('Pages::added', function($event) {
  $page = $event->arguments(0);
  foreach($this->wire->languages as $lang) {
    if($lang->isDefault()) continue;
    $page->set("status$lang", 1);
  }
  $page->save();
});
  • Like 1
Posted

You might want to add an additional

if($page->template != 'your-pagereference-template') return;

inside the hook if you do not want to set all languages active globally on the site...

Posted
5 minutes ago, bernhard said:

You might want to add an additional

if($page->template != 'your-pagereference-template') return;

inside the hook if you do not want to set all languages active globally on the site...

Ok nice! Thanks!

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