Reply to comment

Dynamic Year Display Using PHP

Updating things like a footer or copyright statement seem trivial, but if you have a Dreamweaver site, this could mean updating hundreds or thousands of files. If you created the site correctly, all you have to do is edit one library file to update the text. However, you will still have to FTP the files and ensure nothing gets overwritten in the process. Or worse, if you failed to use templates and library files, you will have to manually edit those pages; not cool.

A better and long term solution would be to have the date dynamically created, that way you never have to worry about this update, ever. Besides saving you time and possibly headaches, it's also a good idea to use this approach because it shows a high level of professionalism and shows clients that you have the future of their site in mind.

Dreamweaver Library Item
Example of a Dreamweaver Library Item

One simple way to do this is using PHP. This code displays a copyright symbol and the current year: &copy; <?php echo date('Y') ;?>

This idea can be used with other programming languages, for example JavaScript.

On Drupal sites, you can add this code to a footer block or to the page.tpl.php. Adding the code to /admin/settings/site-information will not work because PHP isn't allowed.

Footer Output
Footer Output

Reply

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for preventing automated spam submissions.
6 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

About Ishmael


I am a web developer. This is my portfolio. Find out more about me. Contact me about services I can provide.