CMS Development

eliomargarzon
メンバー | Diamond Partner
メンバー | Diamond Partner

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

解決

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 いいね!
1件の承認済みベストアンサー
piersg
解決策
キーアドバイザー

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

解決

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

 

元の投稿で解決策を見る

3件の返信
piersg
解決策
キーアドバイザー

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

解決

@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
投稿者 | Platinum Partner
投稿者 | Platinum Partner

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

解決

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
メンバー | Diamond Partner
メンバー | Diamond Partner

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

解決

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 いいね!