This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation
<?php   }
    }
  if(!$previewMode && $controller->rss) {
    $btID = $b->getBlockTypeID();
    $bt = BlockType::getByID($btID);
    $uh = Loader::helper('concrete/urls');
    $rssUrl = $controller->getRssUrl($b);
?>

Originally posted by pvernaglia at weblicating.com.

 


Three modifications to the Page List block and a Page Attribute will add End Dates to the Page List block.

We had a client who wanted a page of Special Offers that would automatically stop being displayed on a scheduled End Date. We could have used Advanced Permissions to do this, but we wanted something really easy for the client.  We created an "End Date" Page Attribute so the client could add a new page and set the end date right there.  

Step One: Create a new Page Attribute

Go to Dashboard - Pages and Themes, select the Attributes Tab and make a new page Attribute:

offers_attribute.png

Create a new Custom Template for the Page List Block Type

First, if it does not already exist create a directory blocks/page_list/templates. Then, copy the file concrete/blocks/page_list/view.php into the new directory and rename it to something appropriate for your installation.  We will call it offers.php. With your favorite editor open blocks/page_list/templates/offers.php, At the very top of the file you will see two lines of code:

<?php 
  defined('C5_EXECUTE') or die(_("Access Denied."));
  $textHelper = Loader::helper("text"); 

We want to load the Concrete5 Date/Time helper, so add a new line:

<?php
  defined('C5_EXECUTE') or die(_("Access Denied."));
  $textHelper = Loader::helper("text");
  $date = Loader::helper("date");

Just a little further down the file you will find this block of code:

<?php
  for ($i = 0; $i < count($cArray); $i++ ) {
    $cobj = $cArray[$i];
    $title = $cobj->getCollectionName(); ?>

We add and if statement here that checks the End Date against Today's Date.

<?php
  for ($i = 0; $i < count($cArray); $i++ ) {
    $cobj = $cArray[$i];
    $title = $cobj->getCollectionName();
      if($date->getSystemDateTime($cobj->
getCollectionAttributeValue('end_date'))  >  
$date->getLocalDateTime('now')) {
?>

Down toward the bottom of the file look for this block of code:

<?php   }
  if(!$previewMode && $controller->rss) {
    $btID = $b->getBlockTypeID();
    $bt = BlockType::getByID($btID);
    $uh = Loader::helper('concrete/urls');
    $rssUrl = $controller->getRssUrl($b);
?>

We need to add a closing brace for the if statement we just added. It goes at the top of this block of code:

Insert the page List Block on the page you want the Page List to appear and select the template "Offers" (or what ever name you gave it):

offers_template.png
When you add a new page that is associated with this Page List Block enter the expiration date in the "Offers End Date" attribute.  This Page List will display the Titles and Summary Description of all pages that have not yet reached their expiration date.

Loading Conversation