How do I add the copyright date?

Discussion forum for MOD Writers regarding MOD Development.
Locked
cork
Registered User
Posts: 7
Joined: Wed Aug 26, 2009 8:07 am

How do I add the copyright date?

Post by cork »

I would like to add a copyright date (that updates automatically every year) on overall_footer.html.

How do I do this?

Thanks.
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: How do I add the copyright date?

Post by imkingdavid »

You can try this:

Code: Select all

$start = 2010; // The year the site started
$current = date('Y'); // The current year
$date = ($start >= $current) ? $start : $start . '-' . $current; // If it is currently the start year, just return that. otherwise, return the the start year - the current year, e.g. 2010-2011
$template->assign_var('MYCOPYRIGHT', 'Copyright© ' . $date); // Assign that to a template variable for use in your template 
NOTE: I haven't tested this, but it should work. Let me know if you have any errors show up.

That could probably go somewhere in the page_footer() method in includes/functions.php. Then in your template file where you want it to show up, just put {MYCOPYRIGHT} and it will show there.
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
User avatar
Dragosvr92
Registered User
Posts: 1454
Joined: Sat Sep 12, 2009 7:27 am
Location: Romania
Name: Dragos Valentin Rădulescu
Contact:

Re: How do I add the copyright date?

Post by Dragosvr92 »

this is pretty interesting :)
i thought about asking for a function like that i will look in adding it later tomorrow
Formerly known as TheKiller
3.0| Avatar on Memberlist 1.0.3
ChaosBringer
Registered User
Posts: 412
Joined: Mon Apr 19, 2004 11:30 pm
Contact:

Re: How do I add the copyright date?

Post by ChaosBringer »

Yes but by looking at that code i can see that it would only return the difference, you want to add a 20 in front of that. ( Since no one here will be alive by the year 2100 + i suppose )

SO If you dont mind me adding something

Code: Select all

$start = 2010; // The year the site started
$current = date('Y'); // The current year
$date = ($start >= $current) ? $start : $start . '-' . $current; // If it is currently the start year, just return that. otherwise, return the the start year - the current year, e.g. 2010-2011
$template->assign_var('MYCOPYRIGHT', 'Copyright© 20' . $date); // Assign that to a template variable for use in your template
 

01000001 01101100 01101100 00100000 01111001 01101111 01110101 01110010 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01100001 01110010 01100101 00100000 01100010 01100101 01101100 01101111 01101110 01100111 00100000 01110100 01101111 00100000 01110101 01110011 00100001
User avatar
Dragosvr92
Registered User
Posts: 1454
Joined: Sat Sep 12, 2009 7:27 am
Location: Romania
Name: Dragos Valentin Rădulescu
Contact:

Re: How do I add the copyright date?

Post by Dragosvr92 »

so where exactly do i add that script ?
i added it in the functions.php file and it gaved an error
i had find yesterday a php script that dos that but it works just in php and idk where i should add it also
Formerly known as TheKiller
3.0| Avatar on Memberlist 1.0.3
ChaosBringer
Registered User
Posts: 412
Joined: Mon Apr 19, 2004 11:30 pm
Contact:

Re: How do I add the copyright date?

Post by ChaosBringer »

if your going to add it to the functions.php file ( generate footer i think? )

Look for page_footer( ) inside of functions.php

inside that function, go to the last three things it does

Code: Select all

	$template->display('body');

	garbage_collection();
	exit_handler();
Add your code before that.

In your template, add {MYCOPYRIGHT} where you want it to display on either overall footer or simple footer, i dont know which one it is b/c i barely use phpBB any more ( i have my own stuff :P )

01000001 01101100 01101100 00100000 01111001 01101111 01110101 01110010 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01100001 01110010 01100101 00100000 01100010 01100101 01101100 01101111 01101110 01100111 00100000 01110100 01101111 00100000 01110101 01110011 00100001
User avatar
T0ny
Registered User
Posts: 1383
Joined: Sun Jan 29, 2006 8:42 pm
Location: Lancashire
Name: Tony

Re: How do I add the copyright date?

Post by T0ny »

ChaosBringer wrote:Yes but by looking at that code i can see that it would only return the difference
I think you may have misinterpreted the purpose of the minus sign in that code ;)
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: How do I add the copyright date?

Post by imkingdavid »

Yeah, ChaosBringer, I have tested the code I provided on my own server and it works as intended. I then tested your code and it outputs 202010.

The reason is that the minus sign in the code is in single quotation marks, which makes it a string instead of a mathematical operator. It doesn't take the difference of the two numbers, it just adds a - to the output. In other words, if the $start variable is the current year or is somehow after the current year, it will just output the start year (e.g. 2010). If the start year is before the current year, it will output that year, dash, the current year, e.g. 2008-2010. ;)
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
ChaosBringer
Registered User
Posts: 412
Joined: Mon Apr 19, 2004 11:30 pm
Contact:

Re: How do I add the copyright date?

Post by ChaosBringer »

imkingdavid wrote:Yeah, ChaosBringer, I have tested the code I provided on my own server and it works as intended. I then tested your code and it outputs 202010.

The reason is that the minus sign in the code is in single quotation marks, which makes it a string instead of a mathematical operator. It doesn't take the difference of the two numbers, it just adds a - to the output. In other words, if the $start variable is the current year or is somehow after the current year, it will just output the start year (e.g. 2010). If the start year is before the current year, it will output that year, dash, the current year, e.g. 2008-2010. ;)
woops :oops:

Did the location i gave you work tho?

01000001 01101100 01101100 00100000 01111001 01101111 01110101 01110010 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01100001 01110010 01100101 00100000 01100010 01100101 01101100 01101111 01101110 01100111 00100000 01110100 01101111 00100000 01110101 01110011 00100001
User avatar
imkingdavid
Former Team Member
Posts: 2673
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: How do I add the copyright date?

Post by imkingdavid »

Well, I tried to code in the body of a new custom page, not where you suggested so I haven't tried it there yet. But that should work theoretically. :)
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
jcarballo
Registered User
Posts: 2
Joined: Mon Apr 02, 2012 1:37 am
Name: Jose Pablo Carballo

Re: How do I add the copyright date?

Post by jcarballo »

Here is what I did. In file includes/functions.php, in function page_header() they define an array with the variables that may be used at any point by a template. I just added mine in the array.

Code: Select all

	// The following assigns all _common_ variables that may be used at any point in a template.
	$template->assign_vars(array(
		'SITENAME'						=> $config['sitename'],
		'SITE_DESCRIPTION'				=> $config['site_desc'],
...
		'MYCURRENTYEAR'			=> '' . date ('Y'),
	));
Then I was able to use it in the overall_footer.html template.

Code: Select all

Copyright 2010-{MYCURRENTYEAR}
User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: How do I add the copyright date?

Post by Erik Frèrejean »

Keep in mind that, that isn't proper use of the copyright years. Because a year isn't included in that list doesn't mean it isn't copyrighted ;)
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)
User avatar
AmigoJack
Registered User
Posts: 5839
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: How do I add the copyright date?

Post by AmigoJack »

...not to mention that jcarballo's code will only use the date of the server, not any localized one. While one might be sleeping after partying someone elsewhere in the world will still live in the old year. I'm curious if a future date in a copyright voids its validity. ;)
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
jcarballo
Registered User
Posts: 2
Joined: Mon Apr 02, 2012 1:37 am
Name: Jose Pablo Carballo

Re: How do I add the copyright date?

Post by jcarballo »

Using a range of years in a copyright notice is very common. For example, here is how it is specified by GNU.
You can use a range (‘2008-2010’) instead of listing individual years (‘2008, 2009, 2010’) if and only if: 1) every year in the range, inclusive, really is a “copyrightable” year that would be listed individually; and 2) you make an explicit statement in a ‘README’ file about this usage. (http://www.gnu.org/prep/maintain/html_n ... tices.html)
What is wrong about automatic updating the latest year of the copyright is that probably by January 1st (wherever you live) you haven't made your work "copyrightable", you were probably sleeping or something :). Nevertheless, if you're site is pretty much active, I guess this is a trick that works fine for a lot of website owners.
Locked

Return to “[3.0.x] MOD Writers Discussion”