joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.77k stars 3.65k forks source link

wrong ajax requested url on multilingual websites #24315

Closed mikajaxxx closed 2 months ago

mikajaxxx commented 5 years ago

Steps to reproduce the issue

Enable multilingual Enable Remove URL Language Code option in System - Language Filter plugin module in frontend to load articles in ajax

Expected result

in other languages the url of items requested by ajax must have correct link. https://www.example.com/fa/photo/item1

Actual result

the default language is fine. in other languages, The article items loaded by ajax request have no language codes in url https://www.example.com/photo/item1 if i Disable Remove URL Language Code option in System - Language Filter plugin, it works correctly if i move the joomla from root to a folder it works.

System information (as much as possible)

Joomla! 3.9.4 yootheme zoo 3.3.33 roksprocket (mosaic layout to load more items in ajax) multilingual website

Additional comments

it seems the Remove URL Language Code option, also have effect on url of requested ajax url in other languages(not default language) !

infograf768 commented 5 years ago

module in frontend to load articles in ajax

roksprocket (mosaic layout to load more items in ajax)

Do we have such a module in core? Apparently not. I suggest you contact the people providing roksproket as this is not a core issue.

mikajaxxx commented 5 years ago

It is not about roksprocket! it is about the joomla core plugin option that cause conflict with ajax requests!(i mentioned a famous ajax module for testing purpose). i created my own module and the same problem exists! the option i described above in System - Language Filter cause conflict on the ajax requests! no matter which module you want to use!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24315.

infograf768 commented 5 years ago

Sorry, I personally can't help on this as I have no idea of the issue and solution.

if i move the joomla from root to a folder it works.

That would be a hint I guess for anyone concerned and able to provide a patch (if feasible).

mikajaxxx commented 5 years ago

Remove URL Language Code option caused ajax request could not set active language for generated urls. in fact it ignored language code for other langues too! so if we have exception for this option to ignore ajax request in other languages maybe the problem will be solved.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24315.

ReLater commented 5 years ago

I think one have to see some working code to reproduce the issue. Mainly how the request URL is constructed. With or without lang parameter etc. I can just talk about me and I'm not an expert but I always would build AJAX requests in Joomla as non-sef urls (index.php?option=bla&id=blu&lang=xy).

If you have a module. Can you provide it in a reduced form? Rocksproket is too complex.

mikajaxxx commented 5 years ago

"I think one have to see some working code to reproduce the issue."

https://www.webkaj.com/fa/

At the bottom of the page you can see a module (i attached the screen) if you hit load more button the new items has no langueage code in url

"if you have a module. Can you provide it in a reduced form? Rocksproket is too complex."

my module is complex too, but the same result produced all the links produced by JRoute::_();

"but I always would build AJAX requests in Joomla as non-sef urls (index.php?option=bla&id=blu&lang=xy)."

if i disable Remove URL Language Code option or move joomla to subfolder or disable SEF, system works perfectly


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24315.

infograf768 commented 5 years ago

I have installed here roksprocket-2.1.26 on a clean multilingual site (3.9.4). I used one module for en-GB and one for fr-FR, Mozaic Layout. Articles to display are tagged to the same language, as is their category. Protostar default template. Remove URL Language Code set to Yes.

Whatever the site default language selected, I get the correct links.

Note: I always have a menu item of type "List All categories" for each language and hidden.

mikajaxxx commented 5 years ago

Thank you for your time infograf768 could you provide a link to the joomla you have been tested? the joomla is on the root?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24315.

infograf768 commented 5 years ago

joomla tested on localhost as root indeed

mikajaxxx commented 5 years ago

yeah local host doens't show the problem. also on the sub folder! as i mentioned the problem just show up on root of the server! this is really weird situaton! check this: https://www.luxazin.com/en/ on this website i used the exact same module and component but no problem have been showed up!

also in this example i disabled Remove URL Language Code and the system works correctly https://www.luxsima.com/fa

Best


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24315.

ggppdk commented 5 years ago

hhmm i am always adding the current / desired language to my AJAX requests (that are non-sef URLs) i used to have some issues without it, i am not sure (don't remember now it was long time ago) what they were and under which configuration they occurred

mikajaxxx commented 5 years ago

I checked all the codes,and it seems the problem comes form Remove URL Language Code option! i hope someone could help us to solve this problem.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24315.

HLeithner commented 5 years ago

Joomla uses the cookie if no language is given, so maybe it isn't sent with the xhr request?

I can't find the buttons on your site...

mikajaxxx commented 5 years ago

"I can't find the buttons on your site..."

this page has the same module https://www.webkaj.com/fa/projects

"Joomla uses the cookie if no language is given, so maybe it isn't sent with the xhr request?"

It works perfectly in each of these conditions:

HLeithner commented 5 years ago

could you please provide an example, the page you are linking too doesn't have any xhr request.

mikajaxxx commented 5 years ago

"could you please provide an example, the page you are linking too doesn't have any xhr request."

I attached the js and ajax file


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24315.

mikajaxxx commented 5 years ago

sorry it couold not uploaded. i changedajax.txt the file type to txt java.txt


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24315.

mikajaxxx commented 5 years ago

Today i added a simple code for item layout to detect current language for every item:

$lang = JFactory::getLanguage();
echo 'Current language is: ' . $lang->getName();

so it is nothing to do with url and just related to current language

And it seems the problem is because it could not detects current lanague for ajax loaded item; the ajax loaded items show "english" for current language which is default language not the current language!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24315.

brianteeman commented 2 years ago

please delete the spammer

zero-24 commented 2 years ago

Comments deleted.

Hackwar commented 2 months ago

It took a long time, but #43858 should solve your issue. Please help with testing.