verdeandrea Posted June 26, 2015 Share Posted June 26, 2015 Hi guys, i'm working on a multi language website (italian and english) . I'm trying to create a simple tag system using a page as tags container and its children pages as tags. Then in my news template i'm using a page field that allows new pages to be created from this field. Now, everything works fins but when i create a new tag using the page field it actually creates a news page but the name for the second language is not active (see the attached image). If i create a new page using the pages tree the active checkout is already checked. Is there a way to make it automatically active everytime a new page is created using the page field? Thanks a lot Link to comment Share on other sites More sharing options...
LostKobrakai Posted June 27, 2015 Share Posted June 27, 2015 https://processwire-recipes.com/recipes/activate-all-languages/ 1 Link to comment Share on other sites More sharing options...
verdeandrea Posted July 2, 2015 Author Share Posted July 2, 2015 Thanks LostKobrakai. How can i use the snippets you suggested for the admin panel? I'm creating pages using the panel and not via API. Thanks Link to comment Share on other sites More sharing options...
LostKobrakai Posted July 2, 2015 Share Posted July 2, 2015 Oh, didn't read that closely. That not possible right now. I'd suggest posting this over at GitHub. The addition of the pages could easily be made extendable. Link to comment Share on other sites More sharing options...
tpr Posted July 3, 2015 Share Posted July 3, 2015 I'm having the same issue and there are a couple of related issues. I have an autocomplete Page field to add tags (also tried AsmSelect and other types). only the default language "title" is saved field "name" is saved properly only if the admin user language is set to the default language auto "name" generation works only if user lang == default lang (eg. from "title" field, in template Family - Name format for children) non-default language is not activated It's really annoying. I think I have to set up one field for each language but I guess I won't get away without a hook even so. Link to comment Share on other sites More sharing options...
LostKobrakai Posted July 3, 2015 Share Posted July 3, 2015 The problem lies mostly in the interface. It's just not possible to reliably set up multi-language pages by using this textarea. The implementation may be flawed, but really the whole process of adding pages is not great. If you really want those tags to be translated you still need to open the tag's page and add translations. At this point you could've also added the whole thing manually. Not activating the default language makes sense, as the core cannot be certain, that users want untranslated content to show up. As the function creating the pages is already hookable Ryan should just return the new pages and everyone could hook after the creation and add their own logic. Link to comment Share on other sites More sharing options...
tpr Posted July 3, 2015 Share Posted July 3, 2015 I agree, but from the client's POV it is not so convenient to add tags, then go to tags and translate. This would be the best, however, considering the available features. I have only 2 languages now and solved this with 2 fields relatively easily but it's not nice. I'm still hesitating on - forcing the client to translate tags manually, or - save only simple text fields (so no Tags pages to create at all) or leave as it is. Link to comment Share on other sites More sharing options...
verdeandrea Posted July 3, 2015 Author Share Posted July 3, 2015 Another possible and very useful solution could be a field that works like a page field when you choose and existing page but works like a page table field when you create a new one. That would be great not just in this case but in a lot of other cases i can think of. But probably the easiest solution for now is trying to understand if we can change some pw core file to get that result. Link to comment Share on other sites More sharing options...
LostKobrakai Posted July 3, 2015 Share Posted July 3, 2015 Maybe it's already possible. I'm just not sure if the variable will be available to the hook. wire()->addHookAfter("InputfieldPage::processInputAddPages", function($event){ $inputfield = $event->object; $addedPages = $inputfield->pagesAdded; // Change what you need to }); Link to comment Share on other sites More sharing options...
tpr Posted July 4, 2015 Share Posted July 4, 2015 The problem is that not only different page titles are needed but page names too. And another twist is that users may want to add completely different tags per language to a page. Link to comment Share on other sites More sharing options...
LostKobrakai Posted July 4, 2015 Share Posted July 4, 2015 If you need different tags per language then language alternate fields are the way to go. That's not a problem. Link to comment Share on other sites More sharing options...
tpr Posted July 5, 2015 Share Posted July 5, 2015 I know about language alternate fields but it doesn't help much in my current setup. Thanks for the suggestion. I think I will go with the Page Field Edit Links module. It's only one extra step. Link to comment Share on other sites More sharing options...
Can Posted January 14, 2016 Share Posted January 14, 2016 As of PW 2.5.14 you can just copy a wire module to you /site/modules/ folder, make changes and you're good to go (just mentioning ;-) blog post: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/) So I copied InputfieldPage.module and added a few lines (in the code commented with "added by Can" without quotes) My tags field uses InputfieldPageAutocomplete now when entering a tag which isn't present and I'm going to create it, I just enter a colon ( after the title and enter the german one like EnglishTagTitle:DeutscherTagTitel Maybe not the best when you got more languages, but for me it works right now Feel free to copy and of cause adjust anything to fit your needs Make sure to adjust the language in Line 617 Ah, and it's of cause activating the german url as well (regardless if you enter a translation or not..) Here you go: https://gist.github.com/CanRau/e07307fbb5f8daf2c698 Link to comment Share on other sites More sharing options...
Sergio Posted September 18, 2019 Share Posted September 18, 2019 I had the same problem, hope this will help someone. :) I have a multi language website with templates containing a page field called Tags, that the user can create on the fly. Here's a quick way to activate the secondary languages when a new tag is created, using the cool IftRunner module. Install the module https://github.com/ryancramerdesign/IftRunner Create a .module name inside /site/modules/IftRunner using the code below. Install this module "IftActionActivePageLanguages" you just created Go to Setup > Trigger/Action inside the admin dashboard Create a new trigger for a "Pages::saved" hook like the one shown in the screenshot. Spoiler <?php require_once(dirname(__FILE__) . '/IftRunner.module'); class IftActionActivePageLanguages extends IftActionModule implements Module { public static function getModuleInfo() { return array( 'title' => 'Activate all page languages', 'summary' => 'When a page is created using a Page Field, only its default language is activated. This action activates the other languages', 'version' => 1, 'author' => 'Sérgio Jardim', 'requires' => 'IftRunner', ); } public function ___action($item) { $item->setOutputFormatting(false); $languages = wire('languages'); foreach($languages as $lang) { if($lang->isDefault()) continue; $item->set("status$lang", 1); $item->save(); $this->message("All languages activated for page ".$item->url); } } } 4 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