Tuesday, October 5, 2010

Using PHP in your Drupal theme's footer

The problem:
Drupal's footer default message-field (, you can add content from the admin interface - manage > configuration > site information) be PHP parse.
If, for example, you your message footer area such as "© copyright 2009" add a copyright message it will be fine until the new year begins, and you have to go and change it manually in "© copyright 2009".Also, instead it would be great if you date, dynamically can process using the following PHP code (see http://php.net/date for more details of PHP, date):
© Copyright
However, try the standard-' footer message '-added, and it will just spend all of the code as text, ignore the PHP tags.
No PHP in a Drupal footer message
So, what do?
Solution 1:
Create (admin/build/block/add) a block contains code, set its input mask on PHP, and place this block in the footer area on the main blocks settings page (Admin/Build/Block).Crazy easy.)
Please note - You must ensure that you the ' PHP-'-filter module enabled re-start enabled by default in Drupal 6, but is one of the modules 'Core - optional' and can easily be activated via the site admin modules section (admin/build/modules).
Solution 2:
Add the code with the PHP directly in your Drupal theme's page.tpl.php Datei.Um to do so, first open your theme page.tpl.php file and search the footer output, in Garland looks something like:
Please note - there are actually two things, which will spend here:
$ Footer_message - the issue of Drupal's admin ' footer message ' (admin/settings/site info) $ footer is, is the actual footer region (which you can add blocks on the main blocks settings page - admin/build / block)
Then simply insert code wherever you, for example to display the copyright message want (in this case we use the copyright-symbol's html entity number © instead of the symbol correct output - see http://www.w3schools.com/tags/ref_entities.asp for more details):
the result:
PHP in a Drupal theme footer
Problem solved.

View the original article here

No comments:

Post a Comment