Reordering content in lists

September 16, 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 together, generally of the same type (a list of News, a list of Press releases...) but it's not mandatory.

Editors can order items in a content-list either manually or automatically. 

The automatic ordering can be specified in the properties of the list, accessible via 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 its contextual toolbar (or right-click on the list and choose Edit)

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

Note that the Content Lists and Ordering section in the Edit-Form is only available when editing a list or an area.

Manually changing the order of items in a list

You can reorder intems manually directly in your page (using drag and drop to move the content up or down) but doing so in the Edit-Form is most of the time easier, notably if you have a long list of items.  In the Content list & ordering section, click and hold the mousse on the 6 vertical dots in front of a content then move it up or down then release your mouse when the content is at the desired place.

PB-List-editform.png

Automatically changing the order of content

You can use the automatic ordering option 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. With automatic ordering, you don’t have to manually reorder your content when it is edited, or if content is added to the list or removed from the list, the sorting will always remain up to date.

Note: to enable automatic list ordering to your content, your development team must 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.
Important : 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 the Edit-Form of a list / area.

  2. Expand the Content list and ordering section (by clicking on the black chevron)

  3. Click the switch button Automatic ordering to activate

    PB-List-ordering.png

  4. Use the Order by dropdown to select different sorting criteria.

  5. Use the Order direction dropdown to select the sort direction, either ascending or descending.

  6. 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.

  7. Click Save.

Changing the maximum number of items in a content list

When developers create a template, they can specify the maximum number of items that editors will have the right to 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:

  • In Page Composer the Any content button disappears when the maximum number of items set for a list has been reached. If items are removed froml the list, the Any content button will be displayed anew.
  • 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, but the m"aximum" value is applied to define what must be displayed in the page.

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

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

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

    PB-list-nbofitems_closed.png

  3. Input a number in the field 

    PB-list-nbofitems_open.png

  4. Save

In the example above, the maximum number is set to 10. Only the first ten content items included in the list are displayed in your page, even if there are 15 items in this list. If you increase this number, content that was previously hidden will be displayed. If you decrease this number more content will be hidden and less content will be displayed.