Reordering content items in lists

May 31, 2024

A content-list is a particular type of content in Jahia, that does not provide readable information for users but can hold and group multiple items, generally of the same type (a list of News, a list of press releases...). Editors can order items in a content-list either manually or automatically. 

The automatic ordering can be specified in the Edit Form of the list. To open it, as for any other content, select the list in your page then click on the "Edit" button in the contextual toolbar.

With automatic ordering you specify sorting conditions, for example, order by last modified date in ascending order to show most recent content first.

The Content Lists and Ordering section is only available when editing a list or an area.

Manually changing the order of content

You can reorder intems manually directly in your page or through the Edit Form by moving content up or down in drag-and-drop. Click and hold the mousse on the 6 vertical dots in front of a content then move it up or down in the list.

PB-List-editform.png

Automatically changing the order of content

You can use automatic ordering when you’re managing a list of content items or content with subcontent. Automatic ordering enables you to select criteria to sort the content items in the list. With automatic ordering, you don’t have to manually reorder your content and sorting is always up to date.

To add automatic list ordering to your content, the developers you’re working with need to explicitly declare it when defining the content type and add the jmix:automaticallyOrderableList mixin. Developers can refer to the page More on content types to get the details about content types definitions.

Note: Jahia applies automatic list ordering when rendering content. This means ordering is not applied if content is consumed through our GraphQL API. To ensure that the content is always ordered when using Jahia in headless, developers must use sorting capabilities of our API and queries.

By default, the selected criteria used to sort the subcontent is Last modification date and descending . This means that the sub content items are sorted by last modified content first. Depending on the property type, the sort direction is the following:

Type Ascending Descending
String A > Z Z > A
Number 1 > 99999.. 99999.. > 1
Date 01/01/2010 > 01/01/2020 01/01/2020 > 01/01/2010

To enable automatic ordering:

  1. Open content for editing in Content Editor.

  2. Navigate to the Content list and ordering section and enable Automatic ordering.

    PB-List-ordering.png

  3. Use the Order by dropdown to select different sorting criteria. In Order direction, select the sort direction, either ascending or descending.

  4. To add additional sorting criteria, click Add and then specify the sort criteria and direction. You can add two additional sort criteria. If two content items have the same title, content that has been last modified displays first.

  5. Click Save.

Changing the maximum number of items in a content list

When a developer creates a page template, they can specify the maximum number of items that you can add to a content list. You can override the maximum setting if you have the Set content limits on areas permission. By default, the editor-in-chief and site admin roles have this permission. The permission is defined in Administration>Roles and permissions under Permissions on current node>Other permissions.

Use this feature to reduce the number of buttons available for creating content in your pages and to make it easier for authors to drag-and-drop content to the correct location.

Also note that:

  • The Any content button does not display in Page Composer when the maximum number of items has been added to a content list. When you remove items, the Any content button displays again.
  • The maximum setting does not apply to jContent. You can still create as many items as you want in a content list in jContent, regardless of the maximum setting.

To change the maximum number of items in a content list:

  1. In Page Builder open the content list by clicking n the "Edit" button in the upper contextual toolbar.

  2. Click on the button in front of "Number of items"

    PB-list-nbofitems_closed.png

  3. Input a number in the field that is now displayed

    PB-list-nbofitems_open.png

  4. Save

In the example, the maximum number is set to 10. Only the first ten content items included in the list are displayed if you open the page in Preview mode or in Live mode, if you publish it.

Note that this setting only affects how the content list display. The additional content items are not deleted. If you increase the limit, content that was previously hidden will be displayed again.