Solved

Insert "Last Updated" Code in Footer?

Posted on 2013-06-06
6
399 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

710 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