Jump to content

skidr0w

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by skidr0w

  1. That approach works, but is very ugly in my opinion. Is there a reason, why modules ready() method is never triggered?
  2. Thanks for your reply Soma, I tried loading the module with wire('modules')->get('LanguageSupportPageNames'); but this does not change the error. Even though I wrote $user, in my script I used wire('user'). The language change is not adopted by the fields.
  3. Thanks adrian, I already read this thread. The solution to set the $user->language variable temporary and just use $page->url does not work in my case. I'm not sure why, but $user->language is completely ignored in an external script. All fields display in the default language. Setting the $user->language variable does not change this effect.
  4. Hello Processwire community, I try to build an API which works with PW pages as datastore. A reduced example script looks like this: <?php include 'index.php'; // PW bootstrap $sanitizer = wire('sanitizer'); $id = $sanitizer->selectorValue(wire('input')->get->id); $page = wire('pages')->get("id=$id"); $lang_code = $sanitizer->selectorValue(wire('input')->get->lang); $language = wire('languages')->get($lang_code); $page->of(false); $output = array( 'content' => $page->content->getLanguageValue($language), 'url' => $page->localUrl($language), ); header('Content-Type: application/json'); echo json_encode($output); But this does not work as expected. I get the following error, when I call this script: Exception: Method Page::localUrl does not exist or is not callable in this context The "Languages Support - Page Names" module is installed and loaded. I verified this by calling assert(class_exists('LanguageSupportPageNames', false) === true); in the script, which worked. How can I make this script output the localized URL for a page? I hope you can help me.
×
×
  • Create New...