Using PHP In Your Drupal Theme's Footer
The problem:
Drupal’s default 'Footer message' area (to which you can add content via the admin section - Administer > Site configuration > Site information) will not parse PHP.
If, for example, you add a copyright message to your footer message area such as © Copyright 2009
it'll be fine until the New Year begins and you have to go in and manually change it to © Copyright 2010
. So, instead, it would be great if you could handle the date dynamically using the following PHP code (see http://php.net/date for further PHP date details):
© Copyright <span style="color: #000000"><span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y'</span><span style="color: #007700">); </span><span style="color: #0000BB">?></span></span>
However, try adding that to the default 'Footer message' area and it will simply output the entirety of the code as text, ignoring the PHP tags.
So, what to do?
Solution 1:
Create a block (admin/build/block/add
) containing the code, set its input format to PHP, and then place that block in the footer region via the main blocks settings page (admin/build/block
). Crazy simple.