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)

By Mikey - August 10, 2011 - edited: August 11, 2011

I'm building a website that list 800 school schedules.

I need to be able to hide records for 700 of the schools when the month of July rolls around. The 700 schools will remain hidden until Sept starts, at which time the 700 schools will reappear in the list.

I also need to hide the remaining 100 schools of the total 800 schools when the month of August rolls around, then reveal the 100 schools in the list once Sept. rolls around for a total of 800 schools listed.

I then need this to function for every year going forward in the same manner.

Is it possible to create a feature like this that is automated som my client doesn't have to show/hide 800 schools every year using a hidden check box field?

I'm not even sure where to start to build something like this, but I was thinking I'd start with assigning the first 700 to a check box filed called GroupA then assign the remaining 100 schools to GroupB.

From there try to write some kind of string that would hide GroupA for the Months of July and August. then another string that would hide GroupB for the month of August.

Anyone have any suggestions where to begin and if this is even possible?

Thanks, Zick

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>