CMS Development

eliomargarzon
Member | Diamond Partner
Member | Diamond Partner

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

SOLVE

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 Upvotes
1 Accepted solution
piersg
Solution
Key Advisor

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

SOLVE

@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 %}

 

View solution in original post

3 Replies 3
piersg
Solution
Key Advisor

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

SOLVE

@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
Contributor | Platinum Partner
Contributor | Platinum Partner

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

SOLVE

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
Member | Diamond Partner
Member | Diamond Partner

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

SOLVE

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 Upvotes