Last active
December 6, 2018 08:21
-
-
Save hissy/ec41798fed67a70b6c9beb3613d4bb86 to your computer and use it in GitHub Desktop.
#concrete5 #v8 An example of the custom template of page list: filter by date time attribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('C5_EXECUTE') or die("Access Denied."); | |
/** @var \Concrete\Core\Page\PageList $list */ | |
// Start Date is earlier than tomorrow | |
$tomorrow = \Carbon\Carbon::tomorrow(); | |
$list->filterByAttribute('start_date', $tomorrow->format('Y-m-d'), '<'); | |
// End Date is later than today | |
$today = \Carbon\Carbon::today(); | |
$list->filterByAttribute('end_date', $today->format('Y-m-d'), '>='); | |
$list->setItemsPerPage($controller->num); | |
if ($controller->num > 0) { | |
$pagination = $list->getPagination(); | |
$pages = $pagination->getCurrentPageResults(); | |
} else { | |
$pages = $list->getResults(); | |
} | |
$c = Page::getCurrentPage(); | |
/** @var \Concrete\Core\Utility\Service\Text $th */ | |
$th = Core::make('helper/text'); | |
/** @var \Concrete\Core\Localization\Service\Date $dh */ | |
$dh = Core::make('helper/date'); | |
if ($c->isEditMode() && $controller->isBlockEmpty()) { | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment