Sign in

Can I display a condition for displaying published date vs modified date?

  • This topic has 2 replies, 2 voices, and was last updated 1 week, 3 days ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10582
    Avatar photoaleks

    I’m trying to display the last published date of post is more recent than the published date of the post but I’m not sure how to do this. I attempted to do it with {{compare}} but that didn’t work.

    So what I’ve resorted to is the following which doesn’t seem to work very well. If anyone has any advice on how I can display the updated date for a post if it’s more recent than the published date that would be amazing!

    {{#checkIfAny @config.post.displayLastUpdatedDate @config.post.displayDate}}
                            {{#if @config.post.displayLastUpdatedDate}}
                               {{#if modifiedAt}}
                                  <time datetime="{{date createdAt 'YYYY-MM-DDTHH:mm'}}">
                                     {{#checkIf @config.custom.formatDate '!=' 'custom'}}
                                        Last Updated: {{date modifiedAt @config.custom.formatDate}}
                                     {{else}}
                                        Last Updated: {{date modifiedAt @config.custom.formatDateCustom}}
                                     {{/checkIf}}
                                  </time>
                               {{/if}}
                            {{/if}}
                            {{else}}
                                  <time datetime="{{date createdAt 'YYYY-MM-DDTHH:mm'}}">
                                     {{#checkIf @config.custom.formatDate '!=' 'custom'}}
                                        Published: {{date createdAt @config.custom.formatDate}}
                                     {{else}}
                                        Published: {{date createdAt @config.custom.formatDateCustom}}
                                     {{/checkIf}}
                                  </time>
                         {{/checkIfAny}}

     

    #10586
    Avatar photoBob

    You don’t need a condition, just provide a modified date which will return the publish date if the post hasn’t been modified.

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #10592
    Avatar photoaleks

    Thanks Bob understood, however what if I wanted to display text alongside the date to show the text “Published:” along with the published date if the page has not been modified since the date of being published and the text “Updated:” along with the updated date if the page has been modified since the date of being published. Is this possible to do?

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.