Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Insert "Last Updated" Code in Footer?

Posted on 2013-06-06
6
Medium Priority
?
411 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:
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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

722 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