Skip to content

Instantly share code, notes, and snippets.

@waako
Created July 20, 2015 14:56
Show Gist options
  • Save waako/0e7be9d63791d65fe4db to your computer and use it in GitHub Desktop.
Save waako/0e7be9d63791d65fe4db to your computer and use it in GitHub Desktop.
add class to the 1st, and every 3rd and 4th element
<?php $max_delta = count($items) - 1; ?>
<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php if (!$label_hidden): ?>
<div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
<?php endif; ?>
<div class="field-items content"<?php print $content_attributes; ?>>
<?php foreach ($items as $delta => $item): ?>
<?php
$classes = 'grid-3 ';
$tmp = $delta % 4;
// Applies to the first item, then every 4th item
if ($tmp == 0) {
$classes .= ' alpha';
}
// Apples to every 3rd item
elseif ($tmp == 3) {
$classes .= ' omega';
}
?>
<div class=" <?php print $classes; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
<?php endforeach; ?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment