Editing the article's author, date, and timestamp Follow

Comments

7 comments

  • Avatar
    Anthony de Bruyn

    How can I change the published date of individual articles? I am migrating our blog content to Zendesk and would like to timestamp some posts in the past.

  • Avatar
    Laura Hippert

    Hi Anthony!

    The date helper will only display an automated date, based on when the article was created or updated. However, if you wanted to override the date helper for a few select articles, You could implement something like the following:

     <div class="article-updated meta-data">
    {{#is article.id 115002323527}}
    {{t 'updated'}} 2 Years Ago

    {{else}}
    {{t 'updated'}} {{date article.updated_at format="full"}}

    {{/is}}

    You would implement the #is helper to add a manual date (in my example I said "2 Years Ago") for the article that matches the ID that you have referenced. You would need to repeat the #is statement for each migrated article. Once you have done that, the else statement determines that the date helper is used for all other articles, that aren't specifically called out. I hope that helps!

  • Avatar
    Anthony de Bruyn

    Awesome, it works! Thank you!

  • Avatar
    Anthony de Bruyn

    Hello Laura, I was cheering a bit too soon unfortunately ... I'm getting a syntax error when repeating the #is statement:

    <ul class="article-updated meta-data">
    {{#is article.id 115000491434}}
    {{t 'updated'}} 2017-06-02
    {{#is article.id 115000559053}}
    {{t 'updated'}} 2017-06-01
    {{else}}
    {{t 'updated'}} {{date article.updated_at timeago=true}}
    {{/is}}
    </ul>

    What am I doing wrong?

  • Avatar
    Laura Hippert

    Hi Anthony! What you'll actually need to do is close out each individual #is statements at the end, which is why you are getting the syntax error. You'll also want to include the else after each statement, so we can nest them. It will look something like this:

    <ul class="article-updated meta-data">
    {{#is article.id 115000491434}}
    {{t 'updated'}} 2017-06-02
    {{else}}
    {{#is article.id 115000559053}}
    {{t 'updated'}} 2017-06-01
    {{else}}
    {{t 'updated'}} {{date article.updated_at timeago=true}}
    {{/is}}{{/is}}
    </ul>

    Basically, this allows you to nest multiple #is statements, while maintaining one #else statement for the whole lot. 

    Does that help?

  • Avatar
    Anthony de Bruyn

    Works like a charm, thanks!

  • Avatar
    Heather R

    Great article! We commented out the parts we didn't want to display so that we can add them back in easily if we change our minds.

    Thanks again.

Please sign in to leave a comment.

Powered by Zendesk