Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.php > #3195

Re: get pages age

From Ed Mullen <ejEMOVER@edmullen.net>
Newsgroups alt.php
Subject Re: get pages age
Date 2017-07-10 10:43 -0400
Organization Altopia Corp. - Usenet Access - www.altopia.com
Message-ID <afspar.cm4.19.1@news.alt.net> (permalink)
References <afr32o.o3c.19.1@news.alt.net> <esgfunF3a9mU1@mid.individual.net>

Show all headers | View raw


On 7/10/17 at 1:00 AM, J.O. Aho's prodigious digits fired off with great 
aplomb:
> On 07/10/17 01:17, Ed Mullen wrote:
>> So, let's say we have a site with x pages and we would like to create a
>> list of the pages ordered by their last modified date.
>>
>> How to do using any method, maybe PHP.
>>
>> BTW, each page on the site contains this footer code:
>>
>> <?php
>> $current_file_name = ($_SERVER['REQUEST_URI']);
>> $current_path = ($_SERVER['DOCUMENT_ROOT']);
>> $full_name = $current_path.$current_file_name;
>> $last_modified = filemtime($full_name);
>> print("This page last changed: ");
>> print(date("F j, Y - h:i A", $last_modified));
>> print(" USA Eastern Time");
>> ?>
>>
>> which displays the last modified date of each page. Not sure if that
>> even is relevant.
>>
> 
> I'm assuming that your pages are including all the content which is
> static instead of fetching the dynamic data from a database.
> 
> Then you need to begin with list all the pages, you can use the dir()
> function ( http://php.net/manual/en/function.dir.php ) and get the
> filetime() for each file, store those in an array with the time in
> unixtime as the key and the filename as the value, this requires that
> each file has it's unique time, or else you need to have an array of
> file names instead of a single value. Then user ksort (
> http://php.net/manual/en/function.ksort.php ) to sort the values, use
> the numeric sorting.
> 

Thanks for the info.  I'll look into it.


-- 
Ed Mullen
http://edmullen.net/
All of us could take a lesson from the weather. It pays no attention to 
criticism.

Back to alt.php | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

get pages age Ed Mullen <ejEMOVER@edmullen.net> - 2017-07-09 19:17 -0400
  Re: get pages age "J.O. Aho" <user@example.net> - 2017-07-10 07:00 +0200
    Re: get pages age Ed Mullen <ejEMOVER@edmullen.net> - 2017-07-10 10:43 -0400
  Re: get pages age robamman2019@gmail.com - 2019-12-19 04:44 -0800

csiph-web