Cesco Posted January 21, 2022 Share 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. Link to comment Share on other sites More sharing options...
bernhard Posted January 21, 2022 Share 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 Link to comment Share on other sites More sharing options...
Cesco Posted January 21, 2022 Author Share 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 Link to comment Share on other sites More sharing options...
bernhard Posted January 21, 2022 Share 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... Link to comment Share on other sites More sharing options...
Cesco Posted January 21, 2022 Author Share 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! Link to comment Share on other sites More sharing options...
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