showing special by day of week

2 posts by 2 authors in: Forums > CMS Builder
Last Post: February 25, 2011   (RSS)

Re: [rez] showing special by day of week

By Jason - February 25, 2011

Hi,

Since "when" is a multi-value list separated by tab (\t) characters, we first need to break it up into an array. Try using this code:

<?php $today = date("l"); ?>

<?php foreach ($weekly_specialsRecords as $record): ?>

<?php $days = explode( "\t", trim( $record['when'], "\t" ) ); ?>

<?php if ( in_array( $today, $days ) ): ?>
<?php echo $record['title'] ?><br/>
<?php endif ?>

<?php endforeach ?>


Setting something to happen every other Saturday is much more complex because you would need to keep track of which day the product was last displayed.

There are a couple of simpler ways to get this would be to:
a) just turn off that check box every other week
b) have a date field where you set the next date the special is to appear.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/