Skip to content

Instantly share code, notes, and snippets.

@fuddl
Last active December 20, 2015 13:28
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 fuddl/6138623 to your computer and use it in GitHub Desktop.
Save fuddl/6138623 to your computer and use it in GitHub Desktop.
<?php
function nth_child_4n_ds_field_theme_functions_info() {
return array('theme_ds_field_nth_child_4' => t('Highlight 4th child'));
}
function theme_ds_field_nth_child_4($variables) {
$output = '';
// Render the items.
$output .= '<div>';
$i = 1;
$max = count($variables['items']);
foreach ($variables['items'] as $delta => $item) {
$classes = $i % 4 ? 'nth-child-4n' : '';
$output .= '<div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
$i++;
}
$output .= '</div>';
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment