Skip to content

Instantly share code, notes, and snippets.

@benjohnson
Created March 26, 2010 18:51
Show Gist options
  • Save benjohnson/345236 to your computer and use it in GitHub Desktop.
Save benjohnson/345236 to your computer and use it in GitHub Desktop.
<!-- Not possible in Twig --> <? $parties = array_merge($upcoming_local_parties, $upcoming_online_parties);?> <!-- Not possible in Twig -->
<? if(!empty($parties)): ?>
<? $i = 0; ?>
<ul class="cardGrid">
<? foreach ($parties as $party): ?>
<li class="party<? if ($i % 4 == 0) echo " row" ?>"><a href="<?= url::site("parties/profile/{$party['event_id']}"); ?>">
<img src="<?= url::site("{$party['avatar_photo_id']}") . "/100/150"; ?>" alt="<?= $party['name']; ?>" />
<h3><?= $party['name']; ?></h3>
<?
$startTime = strtotime($party['event_start']);
$currentTime = time();
if ($startTime > $currentTime) {
$timeString = 'Starts ';
} else {
$timeString = 'Started ';
}
?>
<p class="bottomStats"><?= $timeString . Toolbox::getTextDate($party['event_start']); ?><? if ($party['event_type'] == 'online') echo " online" ?></p>
</a></li>
<? $i++; endforeach; ?>
</ul>
<? else: ?>
<div class="nothinghere">
<h3>Sorry, there are no parties associated with this movie yet. But, you can <a href="<?= url::site('parties/create/' . $movie['lovecinema_key'])?>">create one!</a></h3>
</div>
<? endif; ?>
================================================================================================
<!-- Not possible in Twig --> <? $parties = array_merge($upcoming_local_parties, $upcoming_online_parties);?> <!-- Not possible in Twig -->
{% macro cardGridRow(number) %}
{% if loop.index % number|default('4') == 4 %}&nbsp;row{% /if %}
{% endmacro %}
<ul class="cardGrid">
{% for party in parties %}
<li class="party{ cardGridRow }"><a href="{ url.site('parties/profile/' ~ party.event_id) }">
<img src="{ url.site(party.avatar_photo_id ~ '/100/150') }" alt="{ party.name }" />
<h3>{ party.name }</h3>
<!-- Whole big chunk of non-display php in the view here. Could potentially do with twig, but probably shouldn't. -->
<p class="bottomStats">{ party.event_start|textdate }{% if party.event_type == 'online' %}online{% /if %}</p>
</a></li>
{% else %}
<li class="nothingHere">Sorry, there were no parties here. Create one!</li>
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment