Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Insert "Last Updated" Code in Footer?

Posted on 2013-06-06
6
Medium Priority
?
418 Views
Last Modified: 2013-06-24
I want to insert a "last updated" snippet in my footer, to change upon any update or addition to content.

What's the easiest approach?

Example:    Last updated:  June 6, 2013
0
Comment
Question by:sandshakimi
6 Comments
 
LVL 11

Expert Comment

by:Guru Ji
ID: 39226414
You can just use getlastmod method in php to accomplish this.

int getlastmod ( void )
Gets the time of the last modification of the current page.

Example

<?php
// outputs e.g. 'Last modified: May 04 2013 20:43:59.'
echo "Last modified: " . date ("F d Y H:i:s.", getlastmod());
?>
0
 
LVL 5

Expert Comment

by:stephencolson
ID: 39226466
As you posted this in the Drupal area, I will assume you want the last modified date of a page in Drupal, not of a basic html (or simple php) file. getlastmod() only works for the file it is called from and doesn't have anything to do with Drupal's content updates.

For some clarification, are you looking for the last date for the site as a whole, or the last update for that specific page?
0
 
LVL 13

Accepted Solution

by:
Aaron Feledy earned 1000 total points
ID: 39226488
I'm not sure there's a clean way to do this in Drupal. You could use the views module to create a block. Your view would need to display only the date updated field of nodes sorted so that the most recent is displayed first. Then you could set your view to only display one result. That would leave you with a block that will only display the date of the most recently updated content.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Assisted Solution

by:stephencolson
stephencolson earned 1000 total points
ID: 39226506
To expand on Arrow's comment a bit, that method would show the most recent content update as far as the entire site is concerned, not necessarily for the page you are on.

If you wanted to restrict the block to showing only for the content page you are on, then you can take the same approach, but add a contextual filter for the node id. In the contextual filter, you can tell it the default behavior should be to hide the block if no node id was found, and then it will not show on your homepage or other dynamic listing pages, but will show on individual content pages.
0
 

Author Comment

by:sandshakimi
ID: 39228708
One code for the whole site, not individual pages.

The update could be anywhere, but is reflected in one date. So perhaps Arrow's approach is sufficient.
0
 
LVL 5

Expert Comment

by:stephencolson
ID: 39228844
Correct, Arrow's approach with a block view should suffice.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question