Hiding a record on a specific date

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

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

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 CommonSenseDesign - March 21, 2014 - edited: March 21, 2014

Hi, Ron.

I replaced that line, as you advised, but all that does is change the date that the record is displayed on the site by one less day. So, for example, if the ad is set to expire on April 30, it shows up on the site as expiring April 29: http://www.newhamburg.ca/offers.php. Also, the ad disappears from the site on the date that's shown on the page.

What I'd like to happen is the following:

1. Set the expiry date in CMSB as April 30.

2. The expiry date of April 30 should be displayed on the site; e.g. on these pages - http://www.newhamburg.ca/offers.php and http://www.newhamburg.ca/offersDetails.php?Dolman-Eyecare-Centre-18.

3. The ad would be hidden from May 1, not April 30; i.e. even if the offer runs out on April 30, the ad should still show up and not be hidden yet.

Regards,

Nigel Gordijk

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