Free modified page list block for sorting event pages by date/time attribute and filtering by custom expiration time
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. ***
All date/time attributes are made available in a select drop down now.
Screenshots of block features:
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());
$columns = $db->MetaColumnNames(CollectionAttributeKey::getDefaultIndexedSearchTable());
And now it works... ??? Is that a good fix, or was there a different reason, better way?
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 126.96.36.199.
After I clean it up and restore the AJAX preview, I can look into putting it on GitHub.
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?
The block needs to be updated and tested with v8.
I will have some time to do that this upcoming week.
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.