Filtering Page List Block by Attribute

Permalink
I'm using the following code, and can't seem to get pages to filter out those pages that have a "Calendar End Date/Time" in the past. How do I get the filtering to work on this attribute?

$now = date('Y-m-d H:i:s');
$pl->filterByAttribute('calendar_event_end_date_time', $now, '>=');

Deladroid
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi Deladroid,

You might find these two links useful for 5.7. They deal with page list filtering by custom attribute.
http://www.concrete5.org/community/forums/5-7-discussion/blog-sorti...
http://www.concrete5.org/index.php?cID=689225...

The Event Date Time List block works, but is very simple. I learned a lot more since I made it and plan to improve it.
Deladroid replied on at Permalink Reply
Deladroid
Thanks for the reply.

I got it working finally in regards to the end-date, but now I'm trying to also filter by the "event is featured" and it is not working.

Here's the debug output for the block:
(mysqlt): select p1.cID, pt.ctHandle from Pages p1 left join Pages p2 on (p1.cPointerID = p2.cID) left join PagePaths on (PagePaths.cID = p1.cID and PagePaths.ppIsCanonical = 1) left join PageSearchIndex psi on (psi.cID = if(p2.cID is null, p1.cID, p2.cID)) inner join CollectionVersions cv on (cv.cID = if(p2.cID is null, p1.cID, p2.cID) and cvID = (select cvID from CollectionVersions where cvIsApproved = 1 and cID = cv.cID)) left join PageTypes pt on pt.ctID = cv.ctID inner join Collections c on (c.cID = if(p2.cID is null, p1.cID, p2.cID)) left join CollectionSearchIndexAttributes on (CollectionSearchIndexAttributes.cID = if (p2.cID is null, p1.cID, p2.cID)) where 1=1 and cvIsApproved = '1' and (p1.cIsTemplate = 0 or p2.cIsTemplate = 0) and ak_calendar_event_end_date_time >= '2015-04-16' and ak_calendar_event_is_featured = '1' and p1.cIsActive = '1' and (p1.cIsSystemPage = 0 or p2.cIsSystemPage = 0) limit 0,20


Here is the snippet from the template view for the page list block:
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$rssUrl = $showRss ? $controller->getRssUrl($b) : '';
$th = Loader::helper('text');
$ih = Loader::helper('image'); 
$today = date("Y-m-d");
$pl = new PageList();
$pl->filterByAttribute('calendar_event_end_date_time', $today, '>=');
$pl->filterByAttribute('calendar_event_is_featured', 1);
$pl->debug();
$pages = $pl->getPage();
?>
<div class="slider-tabs event flexslider">
  <ul class="slides">
    <?php
MrKDilkington replied on at Permalink Reply
MrKDilkington
What version of concrete5 are you using?
Deladroid replied on at Permalink Reply
Deladroid
5.6.3.3
Deladroid replied on at Permalink Reply
Deladroid
Here's my code for the View.php in my custom template. It works without the $eventIsFeatured check in the IF statement, but I can't get it to work when check for both "Event is Featured" (checked; 1) AND "Event End Date" >= "Today".

<?php
defined('C5_EXECUTE') or die("Access Denied.");
$th = Loader::helper('text');
$ih = Loader::helper('image'); 
?>
<div class="slider-tabs event flexslider">
  <ul class="slides">
    <?php 
   foreach ($pages as $page):
      // Title
      $title = '';
      $title = $th->entities($page->getCollectionName());
      // URL
      $url = '';
      $url = $nh->getLinkToCollection($page);