didhavn Posted June 14, 2016 Posted June 14, 2016 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?
didhavn Posted June 14, 2016 Author Posted June 14, 2016 Such a stupid mistake! Thanks soma, I didn't know that I have to set the languages active when creating pages via API Now all works fine, thanks!
didhavn Posted June 14, 2016 Author Posted June 14, 2016 A short followup question: Is it possible to set the status of alternate languages to active of existing pages in the admin-backend?
LostKobrakai Posted June 14, 2016 Posted June 14, 2016 Yeah. There's a checkbox besides the name field(s) for each page.
didhavn Posted June 14, 2016 Author Posted June 14, 2016 Thanks LostKobraKai...I think I have to get my eyes checked
didhavn Posted June 14, 2016 Author Posted June 14, 2016 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?
kixe Posted June 15, 2016 Posted June 15, 2016 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
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