Jump to content

Pages query only showing all results with default language


didhavn
 Share

Recommended Posts

hey all.

i experienced a strange behaviour and wanted to ask if somebody has a solution for this.

i have a page 'POIs' (points of interest) that keeps multiple 'POI' as childs.

each 'POI' should be creatable via frontend through an ajax-call to the page 'create-poi'.

then i have a page 'get-pois' that queries all the pages with template 'poi' and return them.

Home

--> POIs

--> --> POI 1 [*front-end created]

--> --> POI 2 [*front-end created]

--> --> POI X [*back-end created]
--> API

--> --> Create POI

--> --> Get POIs

all works fine except that all the POIs created through the api only show up when 'get-pois' is called from default language.

for example, POI 1 and POI 2 have been create through frontend, POI X in the admin-backend.

now calling localhost/en/api/get-pois outputs all pois, calling localhost/de/api/get-pois outputs only POI X.

all the pois have the required fields in both translations.

can anybody of you think of a solution?

Link to comment
Share on other sites

Sorry, but I have another followup question.

As I described above, I have this 'create-poi' page under parent 'API' to create a poi from frontend. I call this with an ajax call.

I am wondering why the post-data is only transfered when calling the page including the language in the url.

For example, this call with 'en' in the url is successfull. A simple print_r($_POST); in the 'create-poi' returns all data.

$.ajax({
	url: 'en/api/create-poi/',
	type: 'POST',
	data: formData,
	...
});

However, when I call the the page with the following ajax without 'en', the ajax-call hits the page BUT the POST-data is empty. print_r($_POST); returns an empty array.

$.ajax({
	url: 'api/create-poi/',
	type: 'POST',
	data: formData,
	...
});

I don't really have to solve this, as it is working with 'en' in the URL, but I am wondering and curious what is happening there...how can the call successfully hit the page but the POST-data get lost?

Link to comment
Share on other sites

Language redirect is a http request of type 301. For security reasons POST data are dropped in this case.

If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user.

https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2

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...