Last active
December 20, 2015 13:28
-
-
Save fuddl/6138623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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