Jump to content

ajax, $pages->find, current language results


Recommended Posts

Hi,

i only found posts with Ajax +  Search topics, which does not help me with my question i am afraid.

Within a form i narrow down the results to specific conditions (here: countries assigned to continents). While the first select (continents, s. Screen 1) is populated on page load, the second one gets filled up by a ajax call/response (form action attribute references to that ajax driven page). Works well.

What i cannot figure out is why the ajax driven page does not consider the current language when quering pages ($pages->find()) within the ajax page (s. screen 2 (country names should be in english, not in german). As the ajax driven page is a regular PW template based page, i would expect that PW detects the language versions of the page fields automatically like on any other page. Without specifying something additionally.

But obviously not. And i miss something or doing it wrong.

Maybe helpful: 

  • The ajax page is a processwire page derived from a dedicated template.
  • ProcessWire namespace is set (on the ajax driven page)
  • All language checkboxes (Tab settings) in related pages are active
  • Default language is german, both screens showing the page set to english.

Thx in advance for any hint.

cheers
Olaf

Screen 1:

1585343977_Bildschirmfoto2025-04-21um10_16_31.thumb.png.208b7f6792baf989daf208555923bf79.png

Screen 2:

906657085_Bildschirmfoto2025-04-21um10_16_49.thumb.png.8334618560ed8dfed3d0dff64b7736a0.png

Edited by olafgleba
Link to comment
Share on other sites

If I'm not missing something it should be easy: The ajax request will return data in the language that the request was sent to.

  • A request to example.com/whatever would return english
  • A request to example.com/de/was-auch-immer would return german

You just have to make sure to send the request to the correct endpoint.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...