Update Copyright Date Year in Drupal Footer

Author:
phil
Created:
Monday, January 12th, 2009
Last Updated:
Saturday, November 16th, 2013

Disclaimer: Accessing the information on this page means you agree to the Sites Terms of Service


The new year came and went and I was stuck with the annoying task of updating the copyright year in the footer of about 15 different Drupal websites. A long time ago, (When 2008 rolled around) I had tried entering some custom PHP code into Drupal's "site information -> footer" area and quickly found that the drupal site information footer won't accept anything except plain text :( So, I was forced to manually update the sites individually which wasn't a big deal then because I only had to update the copyright date year on about 5 websites.

This year, 2009 rolled around and I decided to try on a Drupal v6 install to again try some custom code in the "site information -> footer" section but was only disappointed.

I pondered for a bit and came up with an idea that I couldn't believe I hadn't thought of before. Scrubbing the "site information -> footer" and simply creating a footer block within Drupal and giving it the PHP Code filter. Much to my surprise, it worked like a charm!

Before writing this post, I did a little searching to find some of the best keywords (and to see if anyone else had a "fix" for this) and ran across this post: http://drupal.org/node/354967
It is basically a short outline of what I am about to explain:

To add a custom footer to Drupal with an automatically updating copyright date year, simply do the following:

1) Create a new block and label it something like "Footer"

2) Change the input field from Filtered or Full HTML to PHP Code (This input filter is not enabled by default in Drupal v6. You will have to visit your modules page and enable it first to have access to it)

3) add the following code to the textarea of your new block:

If you want to show other time or date options, refer to the PHP date options for more information.

Keep in mind that since you are using PHP Code, you will have to do full HTML formatting such as proper <p/> and <br/> tags in order for everything to look right.

From what I can tell, most themes "should" allow the footer block region and it should play nicely. But, there might be an occasional theme where the footer region is either missing or it doesn't play nice.

Hope it helps and good luck formatting Drupal to have an auto updating copyright year!

Update 2011/01/16: Since I'm not a native PHP programmer, I don't exactly know the proper syntax of things... After installing Drupal 7, I received an error that it didn't like the (Y) statement in the code I used to use for Drupal 6 and that it expected ('Y') instead. I've updated the code above to reflect the way it should be and it works for both Drupal 6 and 7.

Update 2013/11/16: Been a while since I've touched on this, but I have to say that the original method of using the PHP code is officially depreciated. Instead, I recommend using the Token Filter module as a much cleaner and more secure alternative.

Check out Auto update to the current year in the copyright footer (© 2010-2013) on Drupal.org for more info

Post Comment