Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Code to display date/time a page within an Index was last modified?


I have a sticky "Last Updated on /Date/ at /Time/" div that I've custom-coded to appear on particular pages of a client's website. Currently, the client needs to go in to the custom code and manually enter the Date and Time whenever they update the page's content.

Is it possible to code this so the date and time automatically update whenever the client makes an edit to the page? There are multiple Indexes that will each need their own unique "updated at" box. It's important for the box to be sticky, visible no matter where you are on the page, because the content that gets updated is long; we want to ensure the user doesn't miss the "updated at" date and time.

Page example w/ current sticky block:

The code is currently located in the PAGE HEADER CODE INJECTION of the Index Settings, and styled with custom css. I'm open to changing the whole set up if I can make it so the client doesn't have to get into the code at all!

Thanks in advance for any and all ideas!

Screen Shot 2019-10-11 at 14.55.28.png

Share this post

Link to post

2 answers to this question

Recommended Posts

  • 2

Hey @alicroft.

This can be done. It requires a short bit of JavaScript to look for the "updated-at" div, query the page's JSON data, find the latest updated collection for the page (or series of pages in the index page), format the date to your liking, and then write the HTML to the "updated-at" div accordingly.

I'd guess it'd take a good dev. and hour or two to write and test an efficient and resilient script to do that (the first half hour to get the "gist" done, then maybe another hour to mess with time formatting, which takes a bit of time without using 3rd-party libs).

So yes, it's possible. Having taken a quick look, I think it could be done without you having to refactor your code at all. You could leave it as you have it on the pages you want it to appear, and the code could be set to run on those pages. If you want more info or help, say the word.

Edited by brandon

If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' vote.jpg.c260784ece77aec852b0e3049c77a607.jpg (top-left)

Share this post

Link to post
  • 0

Thanks so much, @brandon! This is super helpful. I'm going to reach out to my more-experienced-than-me dev friend to see if he can assist in implementing, and if he can't, I'm going to hit you up!

Edited by alicroft

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...