php, page last edited script

Discussion forum for MOD Writers regarding MOD Development.
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

php, page last edited script

Post by stokerpiller »

Hello,

I have a couple of custom pages where I want to display when the pages last was edited/modified.
At the moment I am doing it by hand which is getting boring.
There is a couple of js that does this, but I would like it done in php using the user_date format.

Any help would be appreciated.
I am done with phpBB

stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: php, page last edited script

Post by stokerpiller »

Please dont make me bump this again :D

Can it be done?
I am done with phpBB

User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5450
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: php, page last edited script

Post by Marc »

Yes, it can be done.

Add this to the HTML page of your custom page:

Code: Select all

{LAST_EDITED}
And then add this to your php file:

Code: Select all

$template->assign_var('LAST_EDITED', $user->format_date(time()));

stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: php, page last edited script

Post by stokerpiller »

Thanks for helping me out Marc, but this just displays the time when the page was last viewed.
It changes everytime you refresh the page.

I want to display last edited time = last time the file was uploaded/changed.
I am done with phpBB

User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5450
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: php, page last edited script

Post by Marc »

Sorry, my fault.

You could do it this way:

Code: Select all

$year = 2010;
$month = 9;
$day = 8;
$hour = 13;
$minute = 10;
$second = 05;

$cur_time = mktime($hour, $minute, $second, $month, $day, $year);

$template->assign_var('LAST_EDITED', $user->format_date($cur_time)); 
When you edit the page, just change the info. Note that this should be the GMT time.

stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: php, page last edited script

Post by stokerpiller »

Thanks, but I want it to be automatic.
Theres got to be a way to grab the same info about last change date and time just like your FTP program does.
I am done with phpBB

User avatar
Sierron
Registered User
Posts: 241
Joined: Fri Apr 30, 2010 10:22 am
Location: Germany
Name: Artur
Contact:

Re: php, page last edited script

Post by Sierron »

Multilanguage TimeSplitters Site

If you need support, I suggest you to use the Support Request Template for your questions on this board. If you have some serious problems, the Support Toolkit can fix it (depends on the problem).

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: php, page last edited script

Post by Erik Frèrejean »

Are these pages actual files or dynamically generated from the database? In case of the latter store the timestamp when editing a page and use that. If you are working with actual files you can use filemtime.
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
Marc
Development Team Leader
Development Team Leader
Posts: 5450
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: php, page last edited script

Post by Marc »

I think this function will be easier to use:
http://www.php.net/manual/en/function.getlastmod.php

So you would use it like this:

Code: Select all

$template->assign_var('LAST_EDITED', $user->format_date(getlastmod()));  

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: php, page last edited script

Post by Erik Frèrejean »

Assuming you want to add that line to every file than yes, but you'll probably want to add it to a more generic place for example the function that generates the footer/outputs the page, in which case you'll get the last edited date from the file that contains that code and not the last edited date of the page (file) the user is looking at.
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!)

stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: php, page last edited script

Post by stokerpiller »

marc1706 wrote:I think this function will be easier to use:
http://www.php.net/manual/en/function.getlastmod.php

So you would use it like this:

Code: Select all

$template->assign_var('LAST_EDITED', $user->format_date(getlastmod()));  
Brilliant, that works for the core php files :D
Its good but what if I want it to work with the template and language files?
I am done with phpBB

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: php, page last edited script

Post by Erik Frèrejean »

Erik Frèrejean wrote:Are these pages actual files or dynamically generated from the database? In case of the latter store the timestamp when editing a page and use that. If you are working with actual files you can use filemtime.
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!)

stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: php, page last edited script

Post by stokerpiller »

Erik Frèrejean wrote:
Erik Frèrejean wrote:Are these pages actual files or dynamically generated from the database? In case of the latter store the timestamp when editing a page and use that. If you are working with actual files you can use filemtime.
Nope, the files is only core php, language and template.
Nothing is stored in the DB
I am done with phpBB

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: php, page last edited script

Post by Erik Frèrejean »

Use the php function and pass the file name as parameter ;)
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!)

stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: php, page last edited script

Post by stokerpiller »

I will see if I can figure out how to rewrite it to phpbb :(
I am done with phpBB

Locked

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