Cesco Posted January 21, 2022 Posted January 21, 2022 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.
bernhard Posted January 21, 2022 Posted January 21, 2022 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(); }); 1
Cesco Posted January 21, 2022 Author Posted January 21, 2022 @bernhard Thanks you very much, it works for new pages, for old i update status1021, status1022 fields to "1" directly to db and translation appears. ? 2
bernhard Posted January 21, 2022 Posted January 21, 2022 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...
Cesco Posted January 21, 2022 Author Posted January 21, 2022 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now