Adding the article date to the Article List page

Beantwortet

5 Kommentare

  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Hi @Josh Thiessen,

    you only need to add a helper after the article title, see in the below image how I did:

     

    Code for the same:

    <ul class="meta-group">
    {{#is created_at edited_at}}
    <li class="meta-data">{{date created_at timeago=true}}</li>
    {{else}}
    <li class="meta-data">{{date edited_at timeago=true}}</li>
    <li class="meta-data">{{t 'updated'}}</li>
    {{/is}}
    </ul>

     

     

    Output is:

     

     

     

     

    You can use the date format via https://developer.zendesk.com/documentation/help_center/help-center-templates/helpers/#date-helper

     

    I). Short -

    {{date created_at timeago=true format='short'}}

     

     

    II). Medium-

    {{date created_at timeago=true format='medium'}}

     

     

    III). Medium-

    {{date created_at timeago=true format='long'}}

     

     

    Thanks

    Team

     

     

    1
  • Josh

    @...

    Hi Ifra, That's fantastic. The code you provided works exactly how i was hoping initially. I did run into an issue when I tried to add the medium-sized time stamp (Picture included).

    do you know what I've done wrong?

    Is it also possible to add "updated XXX months ago" instead of just "updated"?

    I was messing around a little, but all the changes i made either had it look like my screenshot or nothing at all.

     

    Thank you so much for the help so far :)

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Hey,  

    You need to add the time format into the updated helper also, see the bold code-line, how I did-

    <ul class="meta-group">
    {{#is created_at edited_at}}
    <li class="meta-data">{{date created_at timeago=true format='medium'}}</li>
    {{else}}
    <li class="meta-data">{{date edited_at timeago=true format='medium'}}</li>
    <li class="meta-data">{{t 'updated'}}</li>
    {{/is}}

     

    The helper 

    <li class="meta-data">{{date edited_at timeago=true format='medium'}}</li>

    shows last date when you have updated the article.

     

    See in the below screenshot, I have updated my article today 17 sep 2021.

     

    and I was created this article on 19 dec 2016

     

    I think you should also try this, if you have any old article, take a screenshot and then update that old article, then compare the date.

     

    also you can add the text for created article, see the bold code-line:

            <ul class="meta-group">
    {{#is created_at edited_at}}
    <li class="meta-data">{{date created_at timeago=true format='medium'}}</li>
    <li class="meta-data">{{t 'created'}}</li>
    {{else}}
    <li class="meta-data">{{date edited_at timeago=true format='medium'}}</li>
    <li class="meta-data">{{t 'updated'}}</li>
    {{/is}}
    </ul>

     

    Output:

     

    If any confusion, let me know :)

    Thanks

    Ifra

     

     

     

    1
  • Josh

    Works Great. Thank you!

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Great!

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.

Powered by Zendesk