Solved

Insert "Last Updated" Code in Footer?

Posted on 2013-06-06
6
388 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now