Tos Web Developer provides insights, tutorials, and advice around topics including content strategy, design, Drupal Development, Drupal Custom Module Development, Drupal 8 Custom themes, PHP, Server, Twig, and more


Ok, we have all seen it (and more than likely been guilty of it at one point or another). The website with the 2004 copyright year in the footer. It does remind your website users that your website hasn't been updated in years but we know you probably had more important things to do than update your footer.
Here is the good news. With Drupal 7 and a little PHP magic, we can solve this problem quickly, easily, and more importantly with almost no effort.

Step 1: Enable the PHP Filter module

Simply go to the modules page at /admin/modules, check off the box next to "PHP filter" and click the "Save configuration" button at the bottom of the page.

Step 2: Create your footer block

Click "Add block" on the block overview page at /admin/structure/block. Add your "Block title", "Block description", and select the region you will like the block to display. This will probably be the footer.

Step 3: Add the PHP code

Next, you need to set the "Text format" to PHP code. Once you have done that you can paste the code below into the "Block body". Be sure to change "YOUR WEBSITE NAME" to the actual name of your website. Also, if you are a fan of the little copyright symbol instead of text you can replace "Copyright" with "©".
Copyright <?php print date('Y', time());?> YOUR WEBSITE NAME. All rights reserved.

That's all folks

You will now see your block with the current year next to the copyright. When next year comes around it will automatically update so your site will never look like an antique! If you have any comments or questions please feel free to leave them below!

No comments:

Post a Comment

| Designed And Blog Post by www.toswebdeveloper.com