User tests: Successful: Unsuccessful:
Pull Request for Issue #22182 .
This fixes menu item type ordering for items starting with lowercase.
Create administrator language override for component name. Change it to start with lowercase, e.g. COM_CONTACTS
="contact".
Create a menu item and choose a menu item type. See ordering of menu item types.
Items sorted alphabetically.
contact
sorted at the bottom.
No.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_menus |
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
Ready to Commit after two successful tests.
The icon issue is probably not one that can be fixed because the icons are being included into the label; we can't try to extract those and sort on the remaining text.
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-09-15 16:28:29 |
Closed_By | ⇒ | mbabker | |
Labels |
Added:
?
|
Thanks for looking. Maybe it is possible to filter the label text to exclude html?
Seems to me some extension developers are trying to get their 'extension' at the top of the list! Suppose in fullness of time that there could be a specific icon field so that the icon is used in the visible but the sort is done on the filtered title. In either scene html filtering would provide a level playing field.
Why not give them all an icon (use a default if not set) ;)
Good idea to have an Icon anyway. Think the Developer just needs to add it into the component title.
But the HTML would still need to be excluded in the search to arrange into proper non case sensitive alpha order. About 9 years ago mariusz.tarnaski at wp dot pl provided a routine in the notes to the php function strip_tags called strip_tags_content that removes the HTML and PHP tags and their content.
See the first contributed note in http://php.net/manual/en/function.strip-tags.php
On second thoughts having generic icons will not help much in sorting by text 'with' icon html text. The icon names will then be used to sort.
The icon should be in its own table column, not in the menu text string. Another Joomla quick fix that became a standard :(
The simplest backward compatible fix is to add an 'order' column to all admin menu items, and then use ORDER BY 'ordering' and then 'title'.
That is already possible if you create custom admin menus
Good idea for some but with the jDownloads component we prefer to keep with 'standard' Joomla! as far as possible.
I'm only going to speak for myself here but I personally don't think we need to be post-processing this text to remove icons. If someone wants to (re-)implement a feature to have this menu support icons with a proper API, by all means go for it, but there is nothing to be gained by stripping HTML from these labels (and no, the inclusion of an icon in the text does not prevent a "level playing field", this isn't the JED where someone tries to "game the system", if anything I would say it's those extension developers introducing UX confusion by adding non-standard output and breaking the alphabetical sorting of the menu and it's not Joomla's responsibility to police it up).
@mbabker Was intrigued when you said "nothing to be gained by stripping HTML from these labels".
So I looked at what was generated and, as I now expected, you were right. So I analysed further.
Basically those with an image have included a space character in the title to separate from the image.
So if a trim() or at least an ltrim() were included in the sort then it would level the playground. The list would then sort and the icon would be irelevant.
See notes in pic below
To do what you want us to do would mean arbitrarily stripping HTML from the titles. Even if the icon is only ignored as it relates to sorting, the string would still have to have the HTML stripped before it could be put into a sort algorithm otherwise you're sorting on something where the first character is <
compared to another something where the first character is a "normal" alphabetic character.
Either we put (back in) support for defining an icon with a proper API or we do nothing. I don't think we need to be doing any kind of extra processing, especially to "level the playing field" because what playing field is there to be leveled in your site's backend? Is it really that big of a competitive advantage that an extension you've already installed (and potentially paid for) might be sorted awkwardly? I said before I would moreso argue is a UX bug with those extensions trying to include the icon than a core bug we need to invest resources into addressing (because those extensions are breaking the expected default alphabetic sorting mechanism by including <img>
tags in their titles).
You misunderstand me! No API is needed, the only change would be to add a trim() in the sort code sequence. Those extensions that are including an icon have a space as the leading character of the text. This space causes the sort to put them in the wrong position. Adding a trim() fuction will just finish the job and it will then not matter if there is or is not an icon.
So I fully agree with your thoughts and observations. There is no need for an API or something so extensive, just a trim() or an ltrim() inclusion in the code, please!
From analysing the results it is now clear that the existing code is fully managing to successfully avoid the html bits and is getting the correct text string for the sort. However the space char has a lower ASCII value than any digit or alpha character so that is the reason for the present sequence.
As you say this is not 'an end of world' issue just a tidy up in search of a tiny improvement to Joomla! which I have been using since version 1.
They do not have to have a space. If the developer is doing this to make their extension appear at the top of the list on purpose then they will always find a way to achieve it. If you really want to ensure its in a different place then you should create your admin menus.
But if they do have a space then it will not sort as intended. There is no presumption that some developers are 'cheating'. Surely just asking for the inclusion of a trim() function in the sort is not a big deal. With that then any extension that 'defeats' the sort is probably doing it deliberately.
We are not post-processing the translation labels. Period.
The component menu list UX is designed to be alphabetical. Trimming it will normalise the results.
And its possible that Joomla, (not the developer) is adding the space (only where there is an icon) in the first place... I'll check..
The ini string for Breezing form is clearly adding the space, not Joomla.
COM_BREEZINGFORMS="<img src="../administrator/components/com_breezingforms/images/icons/component-menu-icons/bf_icon.png" width="23"; /> BreezingForms Free"
As far as I tested, in any case, trimming that space does NOT alpha order the menu.
The reason is very simple: the <
character <
used for the <img src
has a lower value than any letter in the ascii table.
The B
for BreezingForm
is B
http://www.asciitable.com/
IF the string was presented this way (Icon after the title, with a space at the beginning), then trimming would make sense.
COM_BREEZINGFORMS=" BreezingForms Free <img src="../administrator/components/com_breezingforms/images/icons/component-menu-icons/bf_icon.png" width="23"; />"
Let's finish please with this discussion that goes nowhere....
Extension names shouldn't have any HTML. They're meant to be reusable in many different contexts. See their wide use in com_actionlogs
for example.
As noted earlier by infograf768, I can confirm that Developers DO include the spaces themselves, and that removing the icon via an admin language override fixes the issue.
I have tested this item✅ successfully on 2a2a55e
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22189.