joomla / joomla-cms

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

Menu link URL to an in-page anchor ( ...#some-id) not working from a submenu #43324

Open stonebyter opened 2 months ago

stonebyter commented 2 months ago

Steps to reproduce the issue

Add an article 'Music' with two divs that should be navigable with an in-page anchor <div id="video"> and <div="audio">.

Build a menu hierarchy: [Music] URL: index.php?option=com_content&view=article&id=6 -- [Videos] URL: index.php?option=com_content&view=article&id=6#videos -- [Audio]. URL: index.php?option=com_content&view=article&id=6#audio

Expected result

When selecting one of the submenus [Videos] or [Audio] the browser should scroll down to the <div> associated with the menu item.

Actual result

The top of the page is displayed. The browser does not scroll down.

The cause of the problem is, that two itemIds are added to the link. The menu link created/enhanced by Joomla looks as follows: index.php?option=com_content&view=article&id=6&itemId=130#videos&itemId=199

If I manually correct the link and put #videos at the end it works: index.php?option=com_content&view=article&id=6&itemId=130&itemId=199#videos

System information (as much as possible)

Einstellung Wert PHP erstellt für MacBookPro 19.6.0 Darwin Kernel Version 19.6.0: Tue Jun 21 21:18:39 PDT 2022; root:xnu-6153.141.66~1/RELEASE_X86_64 x86_64 Datenbanktyp mysql Datenbankversion 10.4.27-MariaDB Datenbankzeichensatz utf8mb4_general_ci Datenbankverbindungszeichensatz utf8mb4_general_ci Datenbankverbindungsverschlüsselung Keine Datenbankserver unterstützt Verbindungsverschlüsselung Nein PHP-Version 8.2.0 Webserver Apache/2.4.54 (Unix) OpenSSL/1.1.1s PHP/8.2.0 mod_perl/2.0.12 Perl/v5.34.1 PHP-Interface für den Webserver apache2handler Joomla-Version Joomla! 5.1.0 Stable [ Kudumisha ] 16-April-2024 16:00 GMT Joomla Abwärtskompatibilität Plugin Aktiviert () Browsererkennung Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36

Additional comments

brianteeman commented 2 months ago

This is not a joomla bug!!

The problem is that you are not creating the anchors correctly in your content

<div="audio"> is not valid html it must be <div id="audio">

brianteeman commented 2 months ago

Joomla will never create a url like the one you suggest it does as it has two itemid

index.php?option=com_content&view=article&id=6&itemId=130#videos&itemId=199

stonebyter commented 2 months ago

Sorry this was a typo. The div's on my page are correct, the same as you wrote <div id="audio">.

Hmm regarding the URL: I suppose the itemId=130 is the top menu (Music) and the itemId=199 is the submenu (Video). When I check the link, there are really two itemId's and unfortunately the second one (199) is behind the #video for some reasons. The two itemId's are added by Joomla (or maybe by a plugin). I guess it is to track the the menu where the page was called from. In the menu is just the URL index.php?option=com_content&view=article&id=6#videos. From my point of view, the additional itemId's are created by Joomla. I have no idea what else could modify the link...

brianteeman commented 2 months ago

Sorry!!!!!

You are quite correct - thats a new bug as it should not work like that at all

brianteeman commented 2 months ago

What you can do (and I tested myself this time) is to use the sef url instead of the non-sef url.

image

image

anchor

stonebyter commented 2 months ago

Thanks a lot for your help! I really do appreciate your work!

gwstyles commented 2 months ago

In Brian's last post there are 3 links that when clicked on just go to a blank page with "private user image". What is the point if you can't see them?


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

brianteeman commented 2 months ago

@gwstyles thats a limitation of the issues.joomla.org site. If you view it on github itself then you ccan see them - which obviously @stonebyter did https://github.com/joomla/joomla-cms/issues/43324

gwstyles commented 2 months ago

Thank you Brian.


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