In most of the projects that I am working on, it is still common practice to have the current year of the copyright text stored in System > Configuration > General > Design > Footer.
1 |
© 2015 Magento Demo Store. All Rights Reserved. |
That means, every year somebody has to change the year manually. This is very time consuming, especially if you have to manage ten, twenty or more clients. Here is a quick example of how you can make it dynamic.
1. Set a custom string such as {YEAR}
Edit your footer in System > Configuration > General > Design > Footer and place the {YEAR} somewhere.
1 |
© {YEAR} Magento Demo Store. All Rights Reserved. |
2. Replace the {YEAR}
Edit your footer.phtml in your package and replace getCopyright as shown below. For the year I am using Mage::getModel(‘core/date’) to have the correct timezone included.
1 2 3 4 5 6 7 |
<div class="footer-container"> <div class="footer"> <?php echo $this->getChildHtml() ?> <p class="bugs"><?php echo $this->__('Help Us to Keep Magento Healthy') ?> - <a href="http://www.magentocommerce.com/bug-tracking" onclick="this.target='_blank'"><strong><?php echo $this->__('Report All Bugs') ?></strong></a> <?php echo $this->__('(ver. %s)', Mage::getVersion()) ?></p> <address><?php echo str_replace('{YEAR}', Mage::getModel('core/date')->date('Y'), $this->getCopyright()); ?></address> </div> </div> |
File: ./app/design/frontend/{package}/default/template/page/html/footer.phtml