palacios000 Posted May 4, 2015 Share Posted May 4, 2015 hello, Is it possible to get any language field value, specifically for the $page->title? My situation is this: I have the FormBuilder module that generates a page when a user fills the form. If FormBuilder is loaded in the Italian translation, FormBuilder creates a new page with the title in Italian. And if I want to get the title from the API using $page->title nothing comes up. The form is loaded in several languages, so each time the title could be in any language and I don't know which one to pick-up. The "Page Title (Multi-Language)" is very useful for all other pages, but not with the ones created automatically. Is there a way to solve this, something like $page->title_first_available_entry ? Thanks in advance for your help Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 4, 2015 Share Posted May 4, 2015 http://processwire.com/api/multi-language-support/multi-language-fields/#multi-language-field-values 1 Link to comment Share on other sites More sharing options...
palacios000 Posted May 29, 2015 Author Share Posted May 29, 2015 Thank you LostKobrakai! this is how I solved the problem, maybe is not the most elegant but it works if (!$page->title) { $italiano = $languages->get("italiano"); $page->setOutputFormatting(false); $pagetitle = $page->title->getLanguageValue($italiano); // get the unformatted value if (!$pagetitle) { $spanish = $languages->get("spanish"); $page->setOutputFormatting(false); $pagetitle = $page->title->getLanguageValue($spanish); } if (!$pagetitle) { $portuguese = $languages->get("portuguese"); $page->setOutputFormatting(false); $pagetitle = $page->title->getLanguageValue($portuguese); } if (!$pagetitle) { $japanese = $languages->get("japanese"); $page->setOutputFormatting(false); $pagetitle = $page->title->getLanguageValue($japanese); } if (!$pagetitle) { $french = $languages->get("french"); $page->setOutputFormatting(false); $pagetitle = $page->title->getLanguageValue($french); } if (!$pagetitle) { $russian = $languages->get("russian"); $page->setOutputFormatting(false); $pagetitle = $page->title->getLanguageValue($russian); } if (!$pagetitle) { $pagetitle = "E00.000.0"; } $page->set("title", $pagetitle); $page->save("title"); $page->setOutputFormatting(true); } 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