Skip to content

Instantly share code, notes, and snippets.

@paulhuisman
Created November 30, 2012 15:56
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 paulhuisman/4176604 to your computer and use it in GitHub Desktop.
Save paulhuisman/4176604 to your computer and use it in GitHub Desktop.
Modulo and End PHP
<div class="block_content">
<?php $c = 0; foreach ($dossiers as $k => $dossier):
if ($c % 4 == 0) print '<div class="clearfix">';?>
<div class="dossier <?php if ($k % 4 == 3) print 'last'; ?>">
<?php if (!empty($dossier->article_image_filepath)): ?>
<a href="<?php print url('node/'.$dossier->nid); ?>"><?php print theme('imagecache', 'op_list', $dossier->article_image_filepath, '', '', array('class' => 'dossier_img')); ?></a>
<?php endif; ?>
<h4><a href="<?php print url('node/'.$dossier->nid); ?>"><?php print $dossier->title; ?></a></h4>
</div>
<?php if ($c % 4 == 3 || $count == (count($dossiers))) print '</div>';
$c++;
endforeach; ?>
</div>
<?php end($rows); $lastk = key($rows); foreach ($rows as $k => $row): ?>
<div class="article_row <?php if ($k == $lastk) print 'last'; ?> clearfix">
<?php echo the_content(); ?>
</div>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment