GitHub

{{orderby}} helper

{{orderby}} is a helper similar to the {{reverse}} helper - it changes the ordering of the specific collection using your params.

Syntax:

{{orderby collection field direction}}

Example:

{{#each @website.contentStructure.tags}}
{{#checkIf this.name '===' 'test'}}
{{orderby this.posts 'id' 'DESC'}}
{{#each this.posts}}
{{title}}
{{/each}}
{{orderby this.posts 'id' 'ASC'}}
{{/checkIf}}
{{/each}}

In above example we will reverse posts connected with a specific tag using their ID.

Important! You should restore the original ordering after use of the modified output. That's why we are using the {{orderby}} helper two times.

Subscribe

Get the latest Publii news, updates and more delivered directly to your email inbox

You can change your mind at any time by clicking the unsubscribe link in the footer of any email you receive from us, or by contacting us at contact@tidycustoms.net. By clicking below, you agree that we may process your information in accordance with our Privacy Policy.