Skip to content

Instantly share code, notes, and snippets.

@kim3er
Created December 16, 2011 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kim3er/1485670 to your computer and use it in GitHub Desktop.
Save kim3er/1485670 to your computer and use it in GitHub Desktop.
Perch grouping workaround
<div class="fixture-container">
<table>
<thead>
<tr class="date">
<th colspan="7">
December 2011</th>
</tr>
<tr class="titles">
<th class="star">
&nbsp;</th>
<th class="fix-date">
DATE</th>
<th class="ko">
KO</th>
<th class="home-or-away">
V</th>
<th class="opponent">
OPPONENT</th>
<th class="comp">
COMP</th>
<th class="link">
PROMO</th>
</tr>
</thead>
<tbody>
<tr class="home promo">
<td class="star">
&nbsp;</td>
<td class="fix-date">
Fri 16</td>
<td class="ko">
00:00</td>
<td class="home-or-away">
H</td>
<td class="opponent">
MAN U</td>
<td class="comp">
PREM</td>
<td class="link">
<a href="/">VIEW PROMOTION</a>
</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr class="date">
<th colspan="7">
January 2012</th>
</tr>
<tr class="titles">
<th class="star">
&nbsp;</th>
<th class="fix-date">
DATE</th>
<th class="ko">
KO</th>
<th class="home-or-away">
V</th>
<th class="opponent">
OPPONENT</th>
<th class="comp">
COMP</th>
<th class="link">
PROMO</th>
</tr>
</thead>
<tbody>
<tr class="home promo">
<td class="star">
&nbsp;</td>
<td class="fix-date">
Mon 16</td>
<td class="ko">
00:00</td>
<td class="home-or-away">
H</td>
<td class="opponent">
MAN U</td>
<td class="comp">
PREM</td>
<td class="link">
<span>COMING SOON</span>
</td>
</tr>
<tr class="away promo">
<td class="star">
&nbsp;</td>
<td class="fix-date">
Sat 21</td>
<td class="ko">
09:00</td>
<td class="home-or-away">
A</td>
<td class="opponent">
MAN U</td>
<td class="comp">
PREM</td>
<td class="link">
<a href="/">VIEW PROMOTION</a>
</td>
</tr>
<tr class="home promo">
<td class="star">
&nbsp;</td>
<td class="fix-date">
Sat 28</td>
<td class="ko">
00:00</td>
<td class="home-or-away">
H</td>
<td class="opponent">
MAN U</td>
<td class="comp">
PREM</td>
<td class="link">
<span>COMING SOON</span>
</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr class="date">
<th colspan="7">
December 2012</th>
</tr>
<tr class="titles">
<th class="star">
&nbsp;</th>
<th class="fix-date">
DATE</th>
<th class="ko">
KO</th>
<th class="home-or-away">
V</th>
<th class="opponent">
OPPONENT</th>
<th class="comp">
COMP</th>
<th class="link">
PROMO</th>
</tr>
</thead>
<tbody>
<tr class="away no-promo">
<td class="star">
&nbsp;</td>
<td class="fix-date">
Sun 16</td>
<td class="ko">
00:00</td>
<td class="home-or-away">
A</td>
<td class="opponent">
SUPERMAN</td>
<td class="comp">
PREM</td>
<td class="link">
<span>COMING SOON</span>
</td>
</tr>
</div>
<div class="fixture-container">
<?php
$opts = array(
'page'=>'/fixtures/index.php',
'sort'=>'date',
'sort-order'=>'ASC',
'skip-template'=>true,
);
$fixtures = perch_content_custom('Fixtures', $opts);
$date = false;
$first = true;
foreach ($fixtures as $fixture) {
$fixture_date = date("F Y" , strtotime($fixture['date']));
if ($first) {
$first = false;
}
elseif ($fixture_date != $date) {
?>
</tbody>
</table>
<?php
}
if ($fixture_date != $date) {
$date = $fixture_date;
?>
<table>
<thead>
<tr class="date">
<th colspan="7">
<?php echo $fixture_date; ?></th>
</tr>
<tr class="titles">
<th class="star">
&nbsp;</th>
<th class="fix-date">
DATE</th>
<th class="ko">
KO</th>
<th class="home-or-away">
V</th>
<th class="opponent">
OPPONENT</th>
<th class="comp">
COMP</th>
<th class="link">
PROMO</th>
</tr>
</thead>
<tbody>
<?php
}
?>
<tr class="<?php echo $fixture['home_or_away'] == "H" ? "home" : "away" ?> <?php echo ($fixture['home_or_away'] == "H" || (isset($fixture['promo']) && $fixture['promo'] != "")) ? "promo" : "no-promo" ?>">
<td class="star">
&nbsp;</td>
<td class="fix-date">
<?php echo date("D d" , strtotime($fixture['date'])); ?></td>
<td class="ko">
<?php echo date("H:i" , strtotime($fixture['date'])); ?></td>
<td class="home-or-away">
<?php echo $fixture['home_or_away']; ?></td>
<td class="opponent">
<?php echo $fixture['opponent']; ?></td>
<td class="comp">
<?php echo $fixture['competition']; ?></td>
<td class="link">
<?php if (isset($fixture['promo']) && $fixture['promo'] != "") { ?>
<a href="<?php echo $fixture['promo']; ?>">VIEW PROMOTION</a>
<?php } else { ?>
<span>COMING SOON</span>
<?php } ?>
</td>
</tr>
<?php
}
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment