Flashmaster82 Posted October 1, 2023 Share Posted October 1, 2023 I have a field "page reference" name: tags. I have a template that it reference to. In the field i have checked "Allow new pages to be created from field" But when i create a new page from that field only the default language "i have two", is indexed. When i switch to my other language site.com/en/ the new page "tag" will not show up? If i manually add a new page with the template "tag" it will show up on both languages on the page? Link to comment Share on other sites More sharing options...
ngrmm Posted October 6, 2023 Share Posted October 6, 2023 @Flashmaster82 I guess the new page is not activated in your non-default language? Check the settings tab for that. There is a checkbox on the right side of the second language name field. I never experienced this when using the page reference field in the backend, only when you create pages via API/Hooks, you have to activate non-default languages. Is the superuser creating pages via the field using the default language? Link to comment Share on other sites More sharing options...
Flashmaster82 Posted October 6, 2023 Author Share Posted October 6, 2023 Thanks for the reply. The superuser is creating the pages yes. "There is a checkbox on the right side of the second language name field." What checkbox? can´t find it.. I found a settings to disable multiple language support, but thats the opposite.. Link to comment Share on other sites More sharing options...
poljpocket Posted October 8, 2023 Share Posted October 8, 2023 Hi, I believe, I have run into some similar issue. I am creating new pages using the API, something like that: $newPage = $pages->newPage([ 'template' => '...', ... ]); $newPage->set(...); ... $newPage->addStatus(Page::statusUnpublished); foreach($languages->findNonDefault() as $language) $newPage->set("status$language", Page::statusOn); $newPage->save(); If it wasn't for the foreach-loop, the new page is only active in the default language. You can find the checkbox @ngrmm is talking about here: Page edit screen >> Settings >> Name There, the page name is displayed for each language and at the end of the non-default ones, you find said checkbox. This is exactly what my foreach-loop is "checking". Maybe there is an oversight in the Language Support module @ryan? Creating the very same pages in the admin enables the languages by default! Shouldn't the API do the same? @Flashmaster82 is the checkbox marked for you? If not, you might have run into the same "bug" I have... Link to comment Share on other sites More sharing options...
Flashmaster82 Posted October 9, 2023 Author Share Posted October 9, 2023 Im creating new pages in the admin/backend Link to comment Share on other sites More sharing options...
poljpocket Posted October 9, 2023 Share Posted October 9, 2023 Yes I know. You should see the Ekonomi and Finans pages somewhere in the page tree. Depends on how you configured your field. Go to find Ekonomi and edit it via the tree. There you will find the Settings tab and checkbox as described. Is it checked? 1 Link to comment Share on other sites More sharing options...
Flashmaster82 Posted October 9, 2023 Author Share Posted October 9, 2023 Now i see. The active checkbox is not checked.... hmm Link to comment Share on other sites More sharing options...
poljpocket Posted October 9, 2023 Share Posted October 9, 2023 Since this is the second time I see this "issue" arise, I have posted a new issue in the PW-issues repo: https://github.com/processwire/processwire-issues/issues/1826 1 Link to comment Share on other sites More sharing options...
Flashmaster82 Posted October 9, 2023 Author Share Posted October 9, 2023 I found a solution $wire->addHookAfter('Pages::added', function($event) { $page = $event->arguments(0); foreach ($this->wire->languages as $lang) $page->set("status$lang", 1); $page->save(); }); Link to comment Share on other sites More sharing options...
poljpocket Posted October 9, 2023 Share Posted October 9, 2023 (edited) Exactly, I was going to suggest something like that. But be aware of any side effects this might have because this will act on ANY page added and renders the checkmarks on the "Add New Page" screen useless. You might want the hook to be a bit more specific e.g. $wire->addHookAfter('Pages::added(0:template=_YOUR_TAGS_TEMPLATE_NAME_)', ... or also $wire->addHookAfter('Pages::added', function($event) { $page = $event->arguments(0); if ($page->template->name !== '_YOUR_TAGS_TEMPLATE_NAME_') return; foreach ($this->wire->languages as $lang) $page->set("status$lang", 1); $page->save(); }); Still, the better solution would be to eliminate this inconsistency in core / core modules. EDIT: You should only do this for non-default languages, e.g. with $languages->findNonDefault(): $wire->addHookAfter('Pages::added(...)', function($event) { ... foreach ($languages->findNonDefault() as $lang) $page->set("status$lang", 1); ... }); Edited October 9, 2023 by poljpocket 1 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