In admin/structure/menu/manage/account, the "My account" link has "(logged in users only)" appended.
The same should show for "Log out".
Also, it should show not only for menu items provided by the user module, because the same behaviour hold for manually created menu items targeting these paths.
Finally, for "user/login" and "user/register" the opposite holds, and the menu items should be appended "(anonymous users only)".
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | Screenshot_2021-08-07 Edit menu User account menu dev0-web.png | 9.64 KB | quietone |
| #11 | menu_link_appended_text_remove-2268793-11.patch | 2.53 KB | drugan |
| #11 | links.png | 205.78 KB | drugan |
| #6 | menu_link_appended_text_remove-2268793-6.patch | 1003 bytes | wuinfo - bill wu |
| #6 | menu.configure.jpg | 80.99 KB | wuinfo - bill wu |
Comments
Comment #1
panchoComment #2
panchoComment #4
wuinfo - bill wu commentedI would suggest to remove those appended text completely. Links for anonymous user will only show up for an anonymous user. Links for authenticated user will show up on logged in users. The code here have some limitation and is not able to cover all those link. I mean the custom menu links.
Comment #5
wuinfo - bill wu commentedComment #6
wuinfo - bill wu commentedhere is the patch to remove those appended text.
Comment #7
dawehnerWhat about replacing it with some css class, so we can style it just different?
Comment #8
wuinfo - bill wu commentedThanks, @dawehner We can theme it differently now. There is a class there for it.
Comment #9
dawehnerJust adding a tag to ask whether its fine to remove the labels in terms of accessibility? Maybe we could just provide a hidden label by default.
Comment #11
drugan commentedI think that the idea to remove appended text to /user/% links is not a good one because even now we have a lot of questions like "Why my Log in link is not shown" or "Why it is still there after logging in" and removing text will make harder for newcomers to understand how the Drupal works.
Instead we need to extend explanation of workings of those links in an appended text to avoid disambiguation.
Comment #12
pwolanin commentedThis long ternary doesn't make much sense to me nor restricting it to cases where the plugin ID matches
It seems like in this overall stretch of code we should have a $suffix variable that may get populated and then appended in parens if non-empty.
Comment #13
pwolanin commentedAlso - we should consider string freeze? IS this really a big fix?
Comment #14
drugan commentedThe purpose of the ternary is to check if $route is equal to $link->getPluginId(), which only with system provided "Log out" and "My account" are the same, and then check if it is not "My account", which just disappears for anonymous users, not toggles as "Log out" link does. I feel that these conditions might be checked in a more elegant way but for now can't figure out this.
As for the string freeze I do not agree. Just google "drupal 8 log in log out link" and see that the issue continue to appear again and again for at least 5 years long. And now has migrated to drupal 8 in an unchanged state. Let's just say to users that this link works so and so, but the others other way.
Comment #20
chris pergantis commentedJust from the most flexible use point of view. Why not give the admins (or others with edit menu permission) the ability to list links that are restricted from a central control UI. If someone wanted to not have a menu item show they could add that to the list and set permissions. Just before any menu item is being rendered the link contained in the list would then check the permissions of that link before it is rendered. Of course, for ease of use by newbies the list can be preloaded.
Or just add role permissions to each menu item.
In any given case it is the link that a menu item references that is the controlling data field for permitted actions. Why have specialty generated menu items? It is easier for both the development and for the end-user to have a more simple approach. More to read decipher and understand is not necessarily easier.
Comment #23
quietone commentedI have read the issue and I think the problem stated in the IS has become outdated. I have updated the title to reflect what I understand to be the issue being addressed.
On Drupal 9.3.x standard install admin/structure/menu/manage/account looks like this:
Both the My account and the Log out link have explanatory text in parenthesis.
The IS includes another point, changing "user/login" and "user/register". Those links do not appear on the admin page. That, to me, seems like a feature request for a separate issue.
Therefore, closing as outdated. If this is incorrect reopen the issue, by setting the status to 'Active', update the Issue Summary (use the template) add a comment explaining what still needs to be done.
Thanks!