Recent searches


No recent searches

Tip: Display article revision date instead of publication date



Posted Mar 08, 2022

NOTE: If you are using the default ZenDesk Copenhagen theme, this functionality already exists out of the box. We are using a Lotus Theme... specifically: Lotus One and the default date displayed beneath an article author is the "publication date."

I was looking in the ZenDesk help center and community trying to find out how to change the default "publication date" to display the "revision date" for articles. I couldn't find a straight answer (b/c this functionality works, natively) so I adjusted some theme code on our instance and we have it working perfectly now.

See the code snippets at the bottom of this post to see how we updated our code.

  1. Visit Guide Admin
  2. Click the eye icon: "Customize Design" (Themes)
  3. Customize your live theme (but if you are using GitHub sync, you'll need to mod files through Git)
  4. Click the Edit code button
  5. Select the article_page.hbs file (in the templates folder)
  6. Click anywhere in the code section then press CMD+F (to search code)
  7. Search for: created_at
  8. Change the "created_at" to "edited_at" within the "meta" class div

Voila! Now it will display the revision date, instead of the published date. 

We wanted it to look a little different so we changed the theme code a little bit, using the Copenhagen code as our guide. See the details below!

- - -

Copenhagen theme has the following code:

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

- - -

- - -

Original Lotus One code:

<div class="entry-info__content">
{{#if settings.show_article_author}}
<b class="author">
{{#link 'user_profile' id=article.author.id}}
{{article.author.name}}
{{/link}}
</b>
{{/if}}
<div class="meta">{{date article.created_at}}</div>
</div>

This Lotus code will show the Authors name, then right beneath it, it shows the date the article was created or published. This was not good for us. When we updated articles, we wanted to display the date of the most recent update.

- - - 

- - - 

We wanted to display the published date of an article, it's never been updated. If an article has been updated, we wanted to show the word "Updated" and the date of the latest update. We accomplished this by adjusting the following code (in bold). Compare this to the code above, in bold.

<div class="entry-info__content">
{{#if settings.show_article_author}}
<b class="author">
{{#link 'user_profile' id=article.author.id}}
{{article.author.name}}
{{/link}}
</b>
{{/if}}
<div class="meta">
{{#is article.created_at article.edited_at}}
{{date article.created_at timeago=false}}
{{else}}
{{t 'updated'}} {{date article.edited_at timeago=false}}
{{/is}}
</div>
</div>

4

5

5 comments

That's awesome, Jordan, thanks for sharing this!

1


@ beembuilds this code is not working 

<div class="entry-info__content">
{{#if settings.show_article_author}}
<b class="author">
{{#link 'user_profile' id=article.author.id}}
{{article.author.name}}
{{/link}}
</b>
{{/if}}
<div class="meta">{{date article.created_at}}</div>
</div>

1


It worked perfectly (even in French!) thank you very much Jordan Dayton!

0


So helpful and easy to follow - thank you, thank you!

0


So NOT helpful. Please make this easier for end users who do not understand code.

-1


Please sign in to leave a comment.

ADDITIONAL CONTENT

More about

Didn't find what you're looking for?

New post