CMS Development

eliomargarzon
Miembro | Partner nivel Diamond
Miembro | Partner nivel Diamond

How can we change the contents varieble to sort by updated date ?

resolver

In the listing page view we get the contents variable with 10 content object per page sorted by published date, im trying to show my post by updated date, do i can change the contents variable to get sorted by updated date?

thanks in advance.  

0 Me gusta
1 Soluciones aceptada
piersg
Solución
Asesor destacado

How can we change the contents varieble to sort by updated date ?

resolver

@eliomargarzon you can use the sort filter:

{% for content in contents|sort(False, False, 'updated') %}
  Title: {{content.name}}. Updated: {{content.updated|datetimeformat('%d/%m/%Y')}}`).
{% endfor %}

 

Ver la solución en mensaje original publicado

3 Respuestas 3
piersg
Solución
Asesor destacado

How can we change the contents varieble to sort by updated date ?

resolver

@eliomargarzon you can use the sort filter:

{% for content in contents|sort(False, False, 'updated') %}
  Title: {{content.name}}. Updated: {{content.updated|datetimeformat('%d/%m/%Y')}}`).
{% endfor %}

 

narmstrong
Colaborador | Partner nivel Platinum
Colaborador | Partner nivel Platinum

How can we change the contents varieble to sort by updated date ?

resolver

See if this helps.

content.updated
Datetime

A datetime object for when the user last updated the content, in UTC time. This variable can be formatted with the datetime filter. Does not equal content.publish_date on initial publish. Use |between_times filter to test if a post has been updated after publishing.

https://developers.hubspot.com/docs/cms/hubl/variables

Noah Armstrong | TSL Marketing
Senior Developer
6085 Marshalee Dr| Suite 100 | Elkridge, MD 21075
Contact Us

TSL Marketing
eliomargarzon
Miembro | Partner nivel Diamond
Miembro | Partner nivel Diamond

How can we change the contents varieble to sort by updated date ?

resolver

Hi Noah. that attribute is in every content object, but id like to sort the contents object by updated date, by default i found out that this is sorted by published date.

 

i mean if im in the page number one, i will get the 10 latest post published, (and  i can sort this by last updated date, but i dont need this). is there any way to get those post without change the published date manually ?

 thanks btw. 

0 Me gusta