Solved

Insert "Last Updated" Code in Footer?

Posted on 2013-06-06
6
394 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:
Arrow_1 earned 250 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
LVL 5

Assisted Solution

by:stephencolson
stephencolson earned 250 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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 dynamically set the form action using jQuery.

856 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