lpa Posted June 5 Share Posted June 5 We have some CLI and API scripts, that are not bound to Processwire pages/templates. They include PW at the start and then do something like: foreach ( $pages->find('template=item, derp=derpson') as $item ) { echo $item->field_with_multilang; } In these scripts we cannot get PW to honor the default language, user language or anything else. The only way to get this to work is to $item->field_with_multilang->getLanguageValue('default') We're hoping to avoid this because out application is vast, and many modules are used both in $page context and in cli scripts. This mean that we cannot have confidence in the type of the field and writing code like if ( is_string(<field>) ) { do this } else { do that } would cause massive bloat. Please advice. How can we force default language at the start of the script? PS We've already tried stuff like: $user->langauge = $languages->getLanguage('default'); $languages->setLanguage('default'); 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