joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

[5.2] Add the function to order the categories

Open charvimehradu opened this issue 2 years ago • 11 comments

Pull Request for Issue #39532 .

Summary of Changes

  1. Create a field to set the ordering of the categories in the backend.
  2. Add the functionality to order the categories according to the order by query in the database: To determine the ordering for the database query, include the getCategoryOrdering method. The desired category ordering preference is fetched in the getChildrenCategories method, a SQL query is built based on this preference, and the resulting order is used to sort and restructuring the array of child categories. The resulting array $orderedChildrenCategories will contain the children categories sorted as per the Joomla database query order.

Testing Instructions

  • Create different categories and assign them a parent category. (Menu -> Content-> Categories -> New)
  • Move to site modules and add Articles Categories Module (New -> Articles Categories +). Select Parent Category and find the option for Category Ordering just below it and set according to your choice.

image

  • Save the module.

Actual result BEFORE applying this Pull Request

No option to order the categories.

Expected result AFTER applying this Pull Request

You are able to order the categories according to their title and lft values.

https://github.com/joomla/joomla-cms/assets/121369234/89b42954-8bc8-4a4c-b0e0-b21057c468a1

Link to documentations

Please select:

  • [ ] Documentation link for docs.joomla.org:
  • [x] No documentation changes for docs.joomla.org needed
  • [ ] Pull Request link for manual.joomla.org:
  • [x] No documentation changes for manual.joomla.org needed

charvimehradu avatar Aug 08 '23 11:08 charvimehradu

thanks for your pull request, but I think that sorting should be in the categories service and not in the module helper. Also the target branch should be 5.0. @laoneo what do you think?

HLeithner avatar Aug 09 '23 21:08 HLeithner

Hi, @HLeithner thank you for taking the time to review my pull request. I'll wait for your confirmation on the services part since I don't know it well. In the meantime, I've updated the branch to 5.0 as you recommended. Please let me know how you'd like to proceed.

charvimehradu avatar Aug 11 '23 14:08 charvimehradu

I have tested this item :white_check_mark: successfully on 33d9d66469365f5efb47796de5a32879c8ea3202

Tested on Joomla 4.4 with PHP 8.1.22


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

rachelwalraven avatar Aug 26 '23 13:08 rachelwalraven

I have tested this item :white_check_mark: successfully on 453d1dd8698797ce990047c2d5ac7e8e588afb2c

Tested on 5.0.0-beta2-dev - it works as described and makes sense to have Categories in Alpha order. No comment on whether this is the right place for this feature.


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

ceford avatar Sep 09 '23 09:09 ceford

@HLeithner As you moved this PR to draft: Shall we reopen the issue #39532 ?

richard67 avatar Sep 19 '23 08:09 richard67

I change it to draft so it's not merged by accident, I'm not happy with the solution but I think it can be improved. In addition I don't have the time to do this before 5.0.0 release I want to postpone it to maybe 5.1

HLeithner avatar Sep 19 '23 08:09 HLeithner

This pull request has been automatically rebased to 5.1-dev.

HLeithner avatar Sep 30 '23 22:09 HLeithner

I have tested this item :white_check_mark: successfully on 453d1dd8698797ce990047c2d5ac7e8e588afb2c


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

crimle avatar Feb 24 '24 10:02 crimle

This pull request has been automatically rebased to 5.2-dev.

HLeithner avatar Apr 24 '24 09:04 HLeithner

As Joomla 5.2 will have the new articles module that offers this functionality (and more) shouldnt we just close this and leave this module as it is

brianteeman avatar Jul 22 '24 20:07 brianteeman