Hide records during Summer Months, then reveal once summer has ended and repeats annually

3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 11, 2011   (RSS)

Re: [zick] Hide records on specific Month, then reveal once month has passed and cycles annually

By gkornbluth - August 11, 2011

Hi Zick,

I like the idea of a check box but if all you need is July or not July how about expanding on something like this.
<?php $month = date("n")
// "n" shows current month as a number
?>
<?php if ($month == 7 && $record['dont_show_in_july'] == 0): ?>
foreach loop etc.
<?php endif ?>


Have fun.
Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Hide records on specific Month, then reveal once month has passed and cycles annually

By Mikey - August 11, 2011

Hi Zick,

I like the idea of a check box but if all you need is July or not July how about expanding on something like this.
<?php $month = date("n")
// "n" shows current month as a number
?>
<?php if ($month == 7 && $record['dont_show_in_july'] == 0): ?>
foreach loop etc.
<?php endif ?>


Have fun.
Jerry Kornbluth


Jerry, thanks for the help... that little bit of code got the ball rolling. So here's what I came up with. I've done some testing on it and it appears to be working fine, but my test have not been extensive as of yet to find any bugs. This uses a radio button called "groups" with two options "groupA or groupB".

<div id="school_parentCat">

<?php $selectedCat="201"; ?>
<?php foreach($schoolsRecords as $category):?>
<?php if(!$category['_hasParent']):?>
<?php if($category['_isSelected']){echo "<span>"; $selectedCat=$category['num'];} ?>
<a href="?category=<?php echo $category['num']?>"><?php echo $category['name']; ?></a>
<?php if($category['_isSelected']){echo "</span>";} ?>
<?php endif ?>
<?php endforeach ?>
<!-- / school_parentCat --></div>

<?php $count = 0 ?>
<div id="school_list">
<?php if($selectedCat): ?>

<?php $month = date("n") // "n" shows current month as a number
?>

<?php foreach($schoolsRecords as $category): ?>
<?php if ($selectedCat==$category['parentNum']):?>

<?php if ($month == 7 && $category['groups'] == 'groupA' && $category['groups'] == 'groupB' || $month == 8 && $category['groups'] == 'groupB' ): ?>
<!-- if month 7 = groups = groupA + groups = groupB they both cancel each other out, otherwise if month 8 groups = groupB, groupB is shown -->
<div class="schools_list_columns"><p>
<?php $selectedSubCat=$category['num']; ?>
<a href="schools.php?schools_keyword=<?php echo $category['name'] ?>"><?php echo $category['name'] ?></a></p>
<!-- / schools_list_columns --></div>

<?php elseif ($month == 9 || $month == 10 || $month == 11 || $month == 12 || $month == 1 || $month == 2 || $month == 3 || $month == 4 || $month == 5 || $month == 6 ): ?>
<!-- show months = 9-6 and skip months 7-8 -->
<div class="schools_list_columns"><p>
<?php $selectedSubCat=$category['num']; ?>
<a href="schools.php?schools_keyword=<?php echo $category['name'] ?>"><?php echo $category['name'] ?> </a></p>
<!-- / schools_list_columns --></div>

<!-- /months= if statements --><?php endif ?>
<?php $maxCols=2; if (@++$count % $maxCols == 0): ?><div><!-- school_list DIV repeats --><?php endif ?><?php endif ?>
<?php endforeach ?><!-- /school_list DIV repeats --></div>

<!-- / selectedCat if --><?php endif ?>
<!-- / school_list --></div>