Auto copyright date update snippet

Discuss the development and implementation of Joomla! 1.0.x templates here.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Locked
User avatar
hotnuts21
Joomla! Explorer
Joomla! Explorer
Posts: 315
Joined: Wed Aug 17, 2005 11:11 pm

Auto copyright date update snippet

Post by hotnuts21 » Mon Aug 28, 2006 9:30 pm

Here is a little bit of code that you can add to your new template.

Basically it takes the year you create your template, and if its still that year it shows it, if its not it shows the old year and then the new year.

So for exampl if you created your site this year you would want a copyright that looked something like
Copyright your site name 2006.

If your site has been online for a few years you would want a copyright that looked like this
Copyright your site name 2004 - 2006

This code will do this automatically and update each year saving you a bit of time and hassle :)

Code: Select all

<?php 
	$copy = 'Copyright © Your Site Name '; // Change this to suit leave space at end
	$built = '2006'; // This is the year you built the site
	$date = date(Y);
	if ($date == $built) { echo $copy . $built; } else { echo $copy . $built .' - ' . $date; }
	?>
This bit of code is mainly for new sites and you havent been online long enough to have a copyright date spanning two years, if your going to add it to a site that is already older than a year use this alternative. (example uses site created in 2005)

Code: Select all

Copyright © Your Site Name 2005 - <?php echo date(Y); ?>
This will update the latest year automagically as your site goes on.

Hope this helps someone.

Endriago
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Thu Sep 15, 2011 2:55 am
Location: FL, USA
Contact:

Re: Auto copyright date update snippet

Post by Endriago » Sun Jul 27, 2014 3:00 am

A few years and Joomla verision later on, this is still the simplest way to generate a self-updating date (year in this case) for a copyright info. At least the best one I've found so far.

Just wanted to add a way on how to include this PHP code in a module position instead of the template, it is using an extension named "Sourcerer" by NoNumber:

http://extensions.joomla.org/extensions ... ZXIiO30%3D

This extension will allow you to add the above mentioned PHP code (or any other code-language-etc. for that matter) to a module position.

I hope this helps!


Locked

Return to “Templates & CSS - 1.0.x”