Matzn Posted March 13, 2021 Share Posted March 13, 2021 Hi. To manipulate the page output i use the hook Page::render. It works for html, php etc without touch the templatefiles. Example i build a modul called "Mymodul" and integrate some multilanguages fields: class MymodulConfig extends ModuleConfig public function getInputfields() { $inputfields = parent::getInputfields(); $ckeditorToolbar ='Format, Bold, Italic, -, RemoveFormat'; $f = $this->modules->get('InputfieldCKEditor'); $f->toolbar($ckeditorToolbar); $f->attr('name', 'myField'); $f->useLanguages = true; $inputfields->add($f); return $inputfields; } } and add it to all pages: public function ready() { if ($this->page->template != 'admin') { $this->addHookAfter('Page::render', $this, 'addSome'); } } public function addSome($event) { ob_start(); eval('?>'.'<?php echo $this->modules->get('Mymodule')->myField ;?>'. '<?php'); $add = ob_get_contents(); ob_end_clean(); $event->return = str_replace("</body>", $add . "</body>", $event->return); } What i'm missing are the variables for $languages and the switching of the multi languages fields from module. Does somebody has any idea why get only the default language field from modul? Link to comment Share on other sites More sharing options...
Zeka Posted March 13, 2021 Share Posted March 13, 2021 Hi @Matzn Probably you are looking for https://processwire.com/docs/multi-language-support/multi-language-fields/#multi-language-field-values Link to comment Share on other sites More sharing options...
Matzn Posted March 13, 2021 Author Share Posted March 13, 2021 Hi @Zeka some fields from $page are switch in right language, but not the field from modul. It doesn't matter whether I call up the modul-field in the template or via hook. Link to comment Share on other sites More sharing options...
Matzn Posted March 15, 2021 Author Share Posted March 15, 2021 Ok, it seems as if the fields are only translated for the Pageobject. Either you create a page and moves all fields there or you call up the fields of the modules include the suffix as follows: english: myField german: myField__1024 if ($user->language->name != "default") $lable = "__" . $user->language->id; $modules->get('Mymodule')->get("myField$lable"); 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