No Code Attached Yet bug
avatar xjdfhbv
xjdfhbv
29 Dec 2020

In Joomla 3.x (and below), the alias for a menu item of type URL can be used by an external request. For example, if you create a URL menu item with an alias of "fred" and a URL of index.php?option=com_my_component, you can make a request to http://my_site.com/fred and the component will run and deliver its default output. Any extra parameters on the external URL are correctly added to the URL defined in the menu item. So for example if the URL defined in the menu item is index.php?option=com_my_component&task=product_info&format=xml and the external request is http://my_site.com/fred?product=xyz the component is executed with ?option=com_my_component&task=product_info&format=xml&product=xyz

In Joomla 4, such a menu item works correctly when manually clicked on a menu, but an external request for http://my_site.com/fred results in a 404 component not found error.

404
Component not found.

#0 .../libraries/src/Application/SiteApplication.php(206): Joomla\CMS\Component\ComponentHelper::renderComponent(NULL)
#1 .../libraries/src/Application/SiteApplication.php(245): Joomla\CMS\Application\SiteApplication->dispatch()
#2 .../libraries/src/Application/CMSApplication.php(233): Joomla\CMS\Application\SiteApplication->doExecute() 
#3 .../includes/app.php(63): Joomla\CMS\Application\CMSApplication->execute() 
#4 .../index.php(36): require_once('/Applications/X...') 
#5 {main}

[tested in Joomla! 4.0.0-beta5 Beta [ MaƱana ] 27-October-2020 19:41 GMT]

The response has Content-Type:application/xml; so the format=xml parameter is correctly handled, but not the option parameter. It doesn't matter what component is used. You can reproduce this error with any of the built-in components.

Votes

# of Users Experiencing Issue
0/1
Average Importance Score
5.00

avatar xjdfhbv xjdfhbv - open - 29 Dec 2020
avatar joomla-cms-bot joomla-cms-bot - labeled - 29 Dec 2020
avatar Hackwar Hackwar - change - 20 Feb 2023
Labels Added: No Code Attached Yet bug
Removed: ?
avatar Hackwar Hackwar - labeled - 20 Feb 2023
avatar particthistle
particthistle - comment - 21 Aug 2023

In encountering a similar scenario today, and then looking for similar issues, I've found that this currently is by design.

  • The System Links > URL menu item type is not structured as a redirect, but instead when displayed in the menu reverts to displaying what the destination URL is.
  • The alias for the URL menu item type does not directly come into play, and unless there's a Redirect set up in Components > Redirects (J3) or System > Redirects (J4) then the alias will not map to the new destination and will provide a 404 as the alias URL does not exist.
  • You can only visit the System Links > URL menu item type when it's shown in a menu, and when you then hover on the link, you'll only see the final destination URL as the option.

Though I also thought @xjdfhbv logic was initially sound, I soon realised I'd been creating redirects all along and this was the first time I'd been trying the scenario of creating URL items to do what the redirects were doing.

Testing both Redirects and URLS, parsing additional URL parameters does not work. This also appears by design, and when you debug the 404 error, comes at the moment back to an error triggered when the non-SEF URL does not include an option parameter.

Workaround
To create a System Link > URL menu item type that is relying on the alias of an item to redirect or otherwise accept parameters, you need to:

  • create a Redirect that creates the SEF URL and gives it a destination url
  • create a menu item for a System Link > URL and put the redirect URL in as the destination URL.

Future Option
A new menu item type would need to be developed to create the redirect as a menu item type directly. The functionality here would then use the redirect functionality to make the URL use the Alias, and then redirect to the destination URL.

Use scenarios:

  • Creating a list of external resources that you want to have SEF URLS to share with users
  • Managing external resources where the destination may need to change periodically (currently would use Redirects)
  • Using Joomla menu items as a URL Shortening tool
  • Creating redirects that have more functionality than redirects have - eg ability to count hits on the url.
avatar xjdfhbv
xjdfhbv - comment - 21 Aug 2023

Thanks for the analysis particthistle. Yes, this can be closed. I implemented a different solution.

avatar richard67 richard67 - change - 21 Aug 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-08-21 06:25:24
Closed_By richard67
avatar richard67 richard67 - close - 21 Aug 2023
avatar richard67
richard67 - comment - 21 Aug 2023

Closing as expected behavior.

Add a Comment

Login with GitHub to post a comment