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. ***
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. ***
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:
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
to
And now it works... ??? Is that a good fix, or was there a different reason, better way?
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?
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.
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.
Thank you MrK!
Perhaps post this on github.
Hi tallacman,
After I clean it up and restore the AJAX preview, I can look into putting it on GitHub.
After I clean it up and restore the AJAX preview, I can look into putting it on GitHub.
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
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
@studio108
The block needs to be updated and tested with v8.
I will have some time to do that this upcoming week.
The block needs to be updated and tested with v8.
I will have some time to do that this upcoming week.
@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.
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.
Thanks for this MrK!
All date/time attributes are made available in a select drop down now.
Screenshots of block features:
http://imgur.com/a/cFi4z