Hiding a record on a specific date

8 posts by 2 authors in: Forums > CMS Builder
Last Post: March 22, 2014   (RSS)

By CommonSenseDesign - March 20, 2014

I have a page of special offers, which I'd like to hide once the expiry date has arrived: http://www.newhamburg.ca/offers.php

I've used removeDate, which makes the offers disappear when the date arrives. As you can see, the page above shows the expiration date. However, I'd like the ad to appear on this date, and disappear the next day. Is there a way to do this while still showing the correct expiration date on the page? E.g. Offer expires on April 30, but disappears on May 1.

By rconring - March 21, 2014

I have done this on coupons by using -1 day as the expiration text.

<?php echo "Offer Exipres ".date('D, M jS, Y', strtotime('-1 day', strtotime($record['removalDate']))) ?>

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

By CommonSenseDesign - March 21, 2014

Thanks for the reply, Ron. Please can you tell me where I should place your suggested code?

This is my code on the index page:

<table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <?php foreach ($record['logo'] as $index => $upload): ?>
          <td class="tdOffersIndexLogoCell">
            <a href="<?php echo $record['_link'] ?>">
              <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" border="0">
              </a>
            </td>
          <?php endforeach ?>
          <td><img src="images/single-pixel.gif" width="13" height="160" /></td>
          </tr>
        <tr>
          <td><img src="images/single-pixel.gif" width="162" height="1" /></td>
          <td><img src="images/single-pixel.gif" width="6" height="1" /></td>
          </tr>
        <tr>
          <td><p class="pBigLabel" align="center"><strong><a href="<?php echo $record['_link'] ?>">
            <?php echo htmlencode($record['offer_headline']) ?>
            </a></strong></p>
            <p align="center" class="pCaptionNoPad"><em>Offer expires&nbsp;<?php echo date("l, F jS, Y", strtotime($record['removeDate'])) ?>.</em></p></td>
          <td>&nbsp;</td>
          </tr>
        </table>

Thanks!

By rconring - March 21, 2014

You need to modify the Offer Expires line where you are echoing the remove Date.

Replace this:
<?php echo date("l, F jS, Y", strtotime($record['removeDate'])) ?>

with this:

<?php echo date("l, F jS, Y", strtotime('-1 day', strtotime($record['removeDate']))) ?>

The line would then be:

<p align="center" class="pCaptionNoPad"><em>Offer expires&nbsp;<?php echo date("l, F jS, Y", strtotime('-1 day', strtotime($record['removeDate']))) ?>.</em></p></td>

Hope that solves it for you.

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

By rconring - March 22, 2014

Well, the date you should be entering is the REMOVAL DATE (May 1) and not the expiration date of April 30.  As long as the administrator understands that the expiration date that is published is calculated from the removal date it works fine.  I always put a note above the removal date field as a reminder and have never had a problem. (see attached jpg)

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987
Attachments:

removal-date.jpg 24K

By CommonSenseDesign - March 22, 2014

I feel like such a knucklehead - your solution seems so obvious to me now that you pointed that out!

Thanks for your suggestions and patience.

By rconring - March 22, 2014

No need to apologize ... we all do that on occasion.... glad to be of assistance.

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987