2

I have a Joomla extension running on 3.10 which fails on Joomla 4. The issue is that it generates URLs of the form /index.php?option=COMPONENT&view=VIEW&task=TASK&parameter=PARAM which generates a 404 error on J4. I've looked all over the place and can't find anything definitive on these questions

  1. Is there a way to configure J4 to accept this form of URL
  2. If not, what do I need to do to the extension to change it to work on J4

I looked at com_content (which will work with this form of URL) but got lost navigating it.

1
  • Normally, non-SEF URLs should not produce 404 errors (assuming the parameters are correct). Impossible to tell without seeing the code. How is the router implemented?
    – Sharky
    Apr 20 at 7:32

2 Answers 2

0

There are some backward compatibility issues in Joomla 4 when using Joomla 3 code: https://docs.joomla.org/Potential_backward_compatibility_issues_in_Joomla_4

Furthermore are you sure that the 404 errors are caused by the URL structure?

I suspect that there is other code in your component that triggers the error. With a good IDE (like the commercial PHPStorm, or Visual Studio or Netbeans) in combination with Xdebug you can step through the code and see all variables and their values in each step. That way you can analyze where/why the Joomla 3 component is not working.

1
  • The reason I think it's the URL is the stack trace from Joomla debug mode. It's all in the Application and Router, with Router at the top JROOT/libraries/src/Router/Router.php:153
    – John B
    Apr 20 at 13:01
0

The answer is that somewhere in the processing, an href with a relative pathname is handled differently between Joomla 3 and Joomla 4. In Joomla 3, the base site URL is prepended. In Joomla 4, a menu item is prepended (probably the current menu item), which causes it to fail in some cases. In the case I described, the URL was a relative pathname generated within javascript. There are several solutions possible. One is to write a router to handle it. A quicker solution is to generate a full pathname including a correct menu item. The Joomla Uri::base method will get the base site URL. Factory::getApplication()->getMenu()->getActive()->route will give you the menu item subpath.

2
  • Does this question provide resolving advice? If not, then it is Not An Answer. Maybe I am misunderstanding your advice. Might you edit this answer to clarify the advice that you are offering about how to resolve the question?
    – mickmackusa
    Apr 22 at 3:58
  • I updated the answer to show how to resolve this.
    – John B
    Apr 24 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.