CMS Development

JKeith
Miembro

Sorting all blog posts

resolver

Hi,

 

I was easily able to find a way to sort my blog posts by most recently updated using sort:

{% for content in contents|sort(True, False, 'updatedDateTime') %}

 

However, it only sorts the posts in batches according to the pagination, I guess because of lazy loading? The first page is the 12 most recently published posts sorted by the update time, then the second page is the next 12 most recently published sorted by the update time, and so on.  I tried setting a variable before the loop, as in 

{% set sorted_contents = contents|sort(True, False, 'updatedDateTime') %}

and then pass sorted_contents into the for loop, but it didn't work. 

 

Is there a way to sort the entire contents array outside of pagination/lazy loading? Thanks in advance.

0 Me gusta
1 Soluciones aceptada
Kevin-C
Solución
Experto reconocido | Partner
Experto reconocido | Partner

Sorting all blog posts

resolver

Hey @JKeith 

You could use the blog posts API.

Your request could sort parameter to do exactly this!

KevinC_0-1642133896610.png

Ideally this would be returned from a serverless function so the API key isn't exposed.

 

 

EDIT:
This be rather simple using Vue.js!

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

Ver la solución en mensaje original publicado

1 Respuesta 1
Kevin-C
Solución
Experto reconocido | Partner
Experto reconocido | Partner

Sorting all blog posts

resolver

Hey @JKeith 

You could use the blog posts API.

Your request could sort parameter to do exactly this!

KevinC_0-1642133896610.png

Ideally this would be returned from a serverless function so the API key isn't exposed.

 

 

EDIT:
This be rather simple using Vue.js!

Kevin Cornett - Sr. Solutions Architect @ BridgeRev