felted Posted November 15, 2018 Share Posted November 15, 2018 Hello, i get the content of a page with this code: $datenschutz = $pages->get('/datenschutz/'); This are the settings in the BE: But the output in DE and in EN is the same: <?php echo $datenschutz_content->name; ?> <div class="modal-modal mfp-hide" id="<?php echo $datenschutz->name; ?>"> <!-- Output DE: --> <div class="modal-modal mfp-hide" id="datenschutz"> <!-- Output EN: --> <div class="modal-modal mfp-hide" id="datenschutz"> How i get the page name für different languages? Thanks, Detlef Link to comment Share on other sites More sharing options...
louisstephens Posted November 15, 2018 Share Posted November 15, 2018 This might help you out in outputting page names in different languages. https://processwire.com/api/multi-language-support/multi-language-urls/#api Link to comment Share on other sites More sharing options...
felted Posted November 15, 2018 Author Share Posted November 15, 2018 The problem ist, that the site is a onesiter. The URL is always: http://xxx.biz/de/ for german and http://pw.xxx.biz/en/ for english. Any content i get with: $datenschutz_content = $pages->get('/datenschutz/'); <?php echo $datenschutz_content->title; ?> Output (title) for the URL http://xxx.biz/de/ is: datenschutz Output (title) for the URL http://xxx.biz/en/ is: data protection Everthing is fine. But now i need the name of the page datenschutz. If i unterstood correctly, the var $page contains only the content of the current page. So all the examples here are not working. Example: If the URL: http://xxx.biz/de/ I need the page name: datenschutz and if the URL: http://xxx.biz/en/ i need the page name: data_protection (importend is the underscore) I hope, it was a litte understandable ? Thanks, Detlef Link to comment Share on other sites More sharing options...
AndZyk Posted November 15, 2018 Share Posted November 15, 2018 Hello @felted, the translated name should show up, if you are on the translated page: $dataProtection = $pages->get("/datenschutz/"); // German on the default page echo $dataProtection->name; // danteschutz // English on the translated page echo $dataProtection->name; // data_protection If that doesn't work somehow, you could force this as mentioned with localName: // German echo $dataProection->localName("default"); // datenschutz // English echo $dataProtection->localName("english"); // data_protection Or you could try Multi-Language Field Values: $page->of(false); // turn off outputFormatting (if it's not already) // German echo $dataProtection->name->getLanguageValue("default"); // datenschutz // German echo $dataProtection->name->getLanguageValue("default"); // data_protection Important is to pass the language you are looking for. ? Regards, Andreas 1 Link to comment Share on other sites More sharing options...
felted Posted November 19, 2018 Author Share Posted November 19, 2018 This was the trick - thank you! Quote // Germanecho $dataProection->localName("default"); // datenschutz // Englishecho $dataProtection->localName("english"); // data_protection 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