Skip to content

[Feature] Add sorting options to "List All Categories" menu item type #47232

@uzielweb

Description

@uzielweb

Problem Description

Currently, the menu item type "List All Categories in an Article Category Tree" (com_content.categories) does not provide any sorting parameters in its configuration.

While other category views (such as "Category Blog" or "Category List") allow administrators to choose between "Manager Ordering", "Alphabetical", or "Reverse Alphabetical", this specific tree view is hardcoded to follow the manual ordering set in the Category Manager.

For websites with a large volume of categories (e.g., industry directories, event portals), maintaining an alphabetical list via manual drag-and-drop in the backend is extremely inefficient and prone to errors.

Proposed Solution

The goal is to align the com_content.categories view with the "Category Blog" view by adding an orderby_pri (Category Order) parameter to the menu configuration.

Required Changes:

1. Form XML Update

File: administrator/components/com_content/forms/item_categories.xml

A new field should be added to the basic fieldset to allow selection of the sorting method:

<field
    name="orderby_pri"
    type="list"
    label="JGLOBAL_CATEGORY_ORDER_LABEL"
    description="JGLOBAL_CATEGORY_ORDER_DESC"
    default="none"
>
    <option value="none">JGLOBAL_NONE</option>
    <option value="alpha">JGLOBAL_TITLE_ALPHABETICAL</option>
    <option value="ralpha">JGLOBAL_TITLE_REVERSE_ALPHABETICAL</option>
    <option value="order">JGLOBAL_CATEGORY_MANAGER_ORDER</option>
</field>

2. Model Logic Update

File: components/com_content/src/Model/CategoriesModel.php

The getListQuery (or the equivalent method responsible for fetching the tree) needs to be updated to respect this parameter.

Logic Example:

// Retrieve the parameter from the menu item settings
$categoryOrder = $this->params->get('orderby_pri', 'none');

// Apply sorting to the query object
switch ($categoryOrder) {
    case 'alpha':
        $query->order($db->quoteName('a.title') . ' ASC');
        break;
    case 'ralpha':
        $query->order($db->quoteName('a.title') . ' DESC');
        break;
    case 'order':
    default:
        $query->order($db->quoteName('a.ordering') . ' ASC');
        break;
}

Benefits

UX Improvement: Administrators of large portals won't need to manually sort hundreds of categories.

Consistency: Brings parity between different com_content menu types regarding sorting capabilities.

Automation: New categories will automatically fall into the correct alphabetical position without manual intervention.

Environment tested

Joomla 4.4.x / 5.x.x / 6.x.x

Component: com_content

View: categories

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions