Free modified page list block for sorting event pages by date/time attribute and filtering by custom expiration time

Permalink
I was often finding that I needed to sort pages by a date/time attribute type (for events, performances, meetings, etc.) and for only current events to be shown. To do this, I would use a page list block template. The problem with this approach was each template controlled the number of pages returned. I would sometimes end up with multiple templates that did the same thing except that they returned a different number of pages.

I decided to try sorting pages by date/time attribute type and expiration filter in the page list block controller itself. The changes I made were minor and everything seems to work properly (except the AJAX preview). I am sharing this in case someone else might get some use from it.

What it does:
- it sorts pages with a date/time attribute type by the attribute date
- it allows you to set an expiration filter for deciding what pages are current and what pages are filtered out

Examples of how the expiration filter works:
An expiration filter of 1 hour would filter out events older than 1 hour.
An expiration filter of 1 day would filter out events older than 1 day.
An expiration filter of 1 week would filter out events older than 1 week.

Instead of stripping out code, I tried to comment it out. I also commented all the code I added. The AJAX preview was removed though, because it wasn't working anymore.

*** I am offering this modified block as is, with no warranty or guarantee. This is not a beginner level block. ***

MrKDilkington
 
MrKDilkington replied on at Permalink Reply 4 Attachments
MrKDilkington
New version.

All date/time attributes are made available in a select drop down now.

Screenshots of block features:
http://imgur.com/a/cFi4z
tduncandesign replied on at Permalink Reply
tduncandesign
Mr K,

Thanks for the functionality! I had an error, think I fixed it:

When I tried to add this block, got a 500 internal error:
Call to undefined method Application\Block\EventDateTimeList\Controller::getDefaultIndexedSearchTable()


I don't know what the heck I'm doing, but noticed in controller.php, line 133, that term was lacking "Default", so I changed
$columns = $db->MetaColumnNames(CollectionAttributeKey::getIndexedSearchTable());

to
$columns = $db->MetaColumnNames(CollectionAttributeKey::getDefaultIndexedSearchTable());


And now it works... ??? Is that a good fix, or was there a different reason, better way?
MrKDilkington replied on at Permalink Reply 1 Attachment
MrKDilkington
Hi tduncandesign,

There have been changes made to the core since this block was posted last year.

Please find attached the most current version of the add-on that I have. It also includes some example templates for grouping pages by day, day/month, and day/month/year.

I double checked it to make sure it works without errors on 5.7.5.9.
tduncandesign replied on at Permalink Reply
tduncandesign
Thank you MrK!
tallacman replied on at Permalink Reply
tallacman
Perhaps post this on github.
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi tallacman,

After I clean it up and restore the AJAX preview, I can look into putting it on GitHub.
studio108 replied on at Permalink Reply
studio108
I know this is an old post but is the page list filter available for version 8?

I am creating an event section on a clients site and would like the particular Event page to automatically disappear off the page list a day after the event date.

Unless there is a new method in version 8 that I haven't discovered yet?

Many thanks
MrKDilkington replied on at Permalink Reply
MrKDilkington
@studio108

The block needs to be updated and tested with v8.

I will have some time to do that this upcoming week.
MrKDilkington replied on at Permalink Reply 1 Attachment
MrKDilkington
@studio108

I updated the block for v8 and packaged it.

Please find the 0.9 packaged version attached.

Just a reminder, while I have tested the block, it has not been reviewed by a third party, so I recommend testing it first before adding it to a client site.
tduncandesign replied on at Permalink Reply
tduncandesign
Thanks for this MrK!