joomla-cms
joomla-cms copied to clipboard
[4.2] Smart Search Sorting Drop-Down
Summary of Changes
Adds a user defined sorting/ordering capability to the front-end of the Smart Search results. It does that by adding a sorting drop-down above the results.
Testing Instructions
- Apply the PR and run
npm installfor the css to be generated in media. - Visit a Smart Search menu item.
- Under the "Advanced" tab, enable the "Show Sort Fields".
- Select the "Shown Sort Fields".
- In the front-end search for a term that return results. You should see a sorting drop-down with the fields you set.
- Play with the drop-down to change the sorting.
If your "Sort Direction" is set to "Descending", you will NOT see the "Relevance ascending" option. Seems like there is no reason to sort the results by "Relevance ascending".
Actual result BEFORE applying this Pull Request
No front-end sorting.
Expected result AFTER applying this Pull Request
Front-end sorting

Documentation Changes Required
DKN
I can imagine some use cases in which controlling the sort order in the frontend can be really helpful. Maybe it's a good idea to add a background hover to the dropdown.
@sakiss better keep your branch up to date ;)
I have tested this item :red_circle: unsuccessfully on 139672a41ded5c90c28f77b373f45455b6f1742d
As well as the unanswered comment this PR can be marked as unsuccessful as you can not sort by relevance descending
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35993.
I can imagine some use cases in which controlling the sort order in the frontend can be really helpful. Maybe it's a good idea to add a background hover to the dropdown.
@sakiss better keep your branch up to date ;)
The drop-down follows the styling and markup of the language module (possibly elsewhere too).
I have tested this item :white_check_mark: successfully on 4302393300b72020d60dab5f18f54a90b4eb4c83
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35993.
@sakiss Is it correct that "Relevance" only has "descending"? All the other options have both.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35993.
@RickR2H Yes it is how it is designed (see description). I cannot think of a case that a reasonable user sorts the items by "relevance ascending". So this will only be displayed if "relevance ascending" is the default sorting option.
I have tested this item :white_check_mark: successfully on 4302393300b72020d60dab5f18f54a90b4eb4c83
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35993.
RTC
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35993.
This is not correct and should not be rtc https://github.com/joomla/joomla-cms/pull/35993#discussion_r746468229
@brianteeman what exactly is not correct? Plz be clear.
- Should not be possible to display a dropdwon when you have no shown fields


- Should not display fields you have not selected


- No label on the field to tell you what it is - instead of floating randomly on the page


- Relevance
Makes no sense that you can sort by relevance ascending with these options


But not with these options


- Expected to see these new options in the component options as well as the menu
- Update: Done with: https://github.com/joomla/joomla-cms/pull/35993/commits/b724ae1a3e2ec9b193e34a7dbe181cc56c414e9b
- The default value is always added to the drop-down because otherwise the default selection will be irrelevant/out of context.
- Added
- I cannot think of any case that sorting by relevance ascending would make any sense. This is why it is shown only if is set as a default in the backend or is added in the shown fields (relevance with asc direction).
- That would be great and was the 1st thing i developed. Unfortunately it turns out that multi-select parameters are not inherited properly. Instead of showing the selected values shows an "Array" string.
Revert RTC as it needs some rework
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35993.
Changes applied
I still think its wrong that you can have a field shown in the dropdown that is not in the list of fields you mark as shown fields


No label on the field to tell you what it is - instead of floating randomly on the page
Added
Still dont see it
I still think its wrong that you can have a field shown in the dropdown that is not in the list of fields you mark as shown fields
Lets say that we are not including the default field in the 'shown fields' and then perform a search. You will notice the following:
- What you get as the selected sorting field does not match the actual one.
- Changing the sorting field to one of the shown does not let us go back to the default.
In short using a field without displaying it as an option seems a bit dissonant from the user point of view.
Still dont see it
check bf29cb2c85cc9ff4151067a6274cb5924d0b751d
Weirdly when I check out your branch it doesnt show that commit. Anyway I can see it here and it looks ok now - thanks
In short using a field without displaying it as an option seems a bit dissonant from the user point of view.
Perhaps but at the same time it is called "Shown Fields" and you are showing a field that is not there.
User has three fields as shown. They remove one and they still see three in the frontend.
Makes logical sense to a developer but not to a user
Perhaps but at the same time it is called "Shown Fields" and you are showing a field that is not there. User has three fields as shown. They remove one and they still see three in the frontend. Makes logical sense to a developer but not to a user
I agree, that it can be confusing for the admin. My point is not related with the developer but the end user. The front-end users will get something that seems buggy and partially functional. Put yourself in the position of using a search engine that shows a wrong "sort by" field in the 1st place. How would you rate that UX?
@bembelimen could possibly decide on that.
Two options
- Whatever you select in the "show field" is automatically added to the "shown field"
- Change the text to "Additional sort fields" or something like that
I suppose you mean "sort field". This needs work way beyond that PR. 2 can be confusing too. Someone anticipates another "Shown field".
What about adding a description to the field that informs that the default is always there?
What about renaming the field to "Sort Fields". Given that it shows only after the "Show Sort Fields" is enabled, becomes quite evident what is it about. Also the default field is named "Sort Field", hence aggregating them seems valid.
I would appreciate your prompt feedback to catch up the feature freeze.
No. Thats the whole point of my comment. You have fields in the dropdown that are not in the selected field
Fine. I will go on by changing the label to "Additional Sort Fields". Can we go on with that?
Fine. I will go on by changing the label to "Additional Sort Fields". Can we go on with that?
I wouldnt have suggested it otherwise ;)
I have tested this item :white_check_mark: successfully on c072ff171deb092463b2e058f801703a0fcf6ee9
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35993.
@ricardo1709 and @RickR2H Could you please test again?
I have tested this item :white_check_mark: successfully on c072ff171deb092463b2e058f801703a0fcf6ee9
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35993.
RTC
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35993.