[solved] ListItExtended: "last modified"?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
emgaron
Forum Members
Forum Members
Posts: 12
Joined: Tue Jul 10, 2012 6:52 am

[solved] ListItExtended: "last modified"?

Post by emgaron »

I'm busy setting up a small site which uses the ListItExtended module - great module! I'm especially happy with the ability to display the same data in different ways with the templates, so big thanks to the developer!

However, I have one question that I have not found the answer to yet: Is there an easy way to determine (e.g. in a template) when a given list was last modified? The standard {modified_date} only returns the modification date of the page where the ListIt template was included (not unexpected...), but I would like to display the date when the list itself was modified on the page, as the page itself does not change (the only content is a call to a ListIt template).

Any hints (especially RTFMs I might have missed) most welcome!

Thanks in advance,

Thomas
Last edited by emgaron on Thu Feb 28, 2013 7:17 am, edited 1 time in total.
Stikki

Re: ListItExtended: "last modified"?

Post by Stikki »

Howdy,

What you mean by "list"

List consist of items, list it self has no time stamps, neither does items, before 1.4 is out. And no i don't know when that's going to happen.

-Stikki-
emgaron
Forum Members
Forum Members
Posts: 12
Joined: Tue Jul 10, 2012 6:52 am

Re: ListItExtended: "last modified"?

Post by emgaron »

With 'list', I mean the content of a given instance (is that the right term in this context?) - e.g. I have a ListIt instance that is used to list a number of people with several fields for each name. This content changes rather frequently (can be daily) and for the users of that particular site it would be nice to see when that content was changed. If that's not possible, I'll just have to educate the folks who will be looking after the content of this list to update the date on the page where the list is displayed each time they add or modify something to/in the list.

Regards,
Thomas
Stikki

Re: ListItExtended: "last modified"?

Post by Stikki »

There is event: PostItemSave

Which is sent each time some of item is saved in that instance.

So you could make UDT that is called when event is executed and update some file or own database for timestamp.

But there is no ready solution for that. And only items will be getting modified timestamp in future, not list itself.

-Stikki-
emgaron
Forum Members
Forum Members
Posts: 12
Joined: Tue Jul 10, 2012 6:52 am

Re: ListItExtended: "last modified"?

Post by emgaron »

Stikki wrote:There is event: PostItemSave

Which is sent each time some of item is saved in that instance.
Thanks - that sounds as if it might do the job. I'll try and dig into that - so far, I've only found documentation that UDTs can handle events, but not yet how. If somebody happens to have a pointer to relevant documentation (so far, I came up empty using the search function, but I haven't given up yet...), I'd be much obliged.

Cheerio,
Thomas
emgaron
Forum Members
Forum Members
Posts: 12
Joined: Tue Jul 10, 2012 6:52 am

[SOLVED] Re: ListItExtended: "last modified"?

Post by emgaron »

Never mind, I finally found the Event Manager and that set me going. I made two UDT that update/read a timestamp file and get the desired effect that way.
emgaron
Forum Members
Forum Members
Posts: 12
Joined: Tue Jul 10, 2012 6:52 am

Re: [solved] ListItExtended: "last modified"?

Post by emgaron »

...and to give other folks who might be looking for a solution to this problem a head start, I'll include the UDTs I'm using.

WARNING! As this code is used for a "nice to have" functionality only on a small, internal (i.e. no connection to the Internet) site with only a few trusted admins/editors, I can get away with keeping the UDTs very simple - there is no error checking, for example. Be aware of this should you decide to use any of this!

Any hints for improvements are nonetheless always welcome!

UDT1: "ListItLastModified"
This UDT is coupled to the "PostItemSave" event of the ListIt-instance that you want the "last modified" date of. All the UDT does is write the current time (in "seconds since epoch" format) to a fixed file whenever it is called (One could use the DB to store this, but a file was easier to implement for me). That way, the file gets updated with the current time when the list is "submitted".

The code:

Code: Select all

$timestamp_file = "/SOME/PATH/THE/WEBSERVER/MAY/WRITE/TO/TIMESTAMPFILE.txt";
$fh = fopen($timestamp_file, 'w');
fwrite($fh,time()."\n");
fclose($fh);
UDT2: "ListItLastModified_print"
This UDT simply reads the timestamp file and prints its contents. "date_format" can then be used for proper formatting.

The code:

Code: Select all

$timestamp_file = "/SOME/PATH/THE/WEBSERVER/MAY/WRITE/TO/TIMESTAMPFILE.txt";
$fh = fopen($timestamp_file, 'r');
$timestamp = fread($fh,filesize($timestamp_file));
fclose($fh);
echo $timestamp;
The second UDT can then be placed wherever you would like to display the modification date, e.g. like this:

Code: Select all

{ListItLastModified_print|date_format:"%d/%m/%Y"}
As mentioned above, this is basically quick-hack code and it could (and probably should...) be more robust - you have been warned...

Cheerio,
Thomas
Post Reply

Return to “Modules/Add-Ons”