Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active December 6, 2018 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/ec41798fed67a70b6c9beb3613d4bb86 to your computer and use it in GitHub Desktop.
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
<?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