Drupal 7
You should be able to copy this function into your template.php
file of your theme:
/**
* Process variables for paragraphs-items.tpl.php
*/
function mytheme_preprocess_paragraphs_items(&$variables, $hook) {
$variables['view_mode'] = $variables['element']['#view_mode'];
$variables['field_name'] = $variables['element']['#field_name'];
$variables['content'] = $variables['element']['#children'];
$variables['classes_array'][] = drupal_html_class('paragraphs-items-' . $variables['element']['#field_name']);
$variables['classes_array'][] = drupal_html_class('paragraphs-items-' . $variables['element']['#field_name'] . '-' . $variables['view_mode']);
$variables['classes_array'][] = drupal_html_class('paragraphs-items-' . $variables['view_mode']);
$variables['theme_hook_suggestions'][] = 'paragraphs_items__' . $variables['element']['#field_name'];
$variables['theme_hook_suggestions'][] = 'paragraphs_items__' . $variables['element']['#field_name'] . '__' . $variables['view_mode'];
// your code here
$variables['classes_array'][] = 'your-class';
$variables['classes_array'][] = 'your-other-class';
}
You should also be able to do this for individual item:
/**
* Process variables for paragraphs-item.tpl.php
*/
function mytheme_preprocess_paragraphs_item(&$variables, $hook) {
// your code here
$variables['classes_array'][] = 'your-class';
$variables['classes_array'][] = 'your-other-class';
}
After adding this function, clear the cache so it is registered. You can then check if either one are being called by adding a breakpoint or print 'called'; exit;
if you do not have something like XDebug installed.
Note how the second function is paragraphs_item
and not paragraphs_items
. Both of these are defined as theme hooks in paragraphs.module.
You can even do this as well:
/**
* Implements hook_preprocess_entity().
* @param $variables
*/
function mytheme_preprocess_entity(&$variables) {
if ($variables['entity_type'] == 'paragraphs_item' && $variables['elements']['#bundle'] == 'your_bundle') {
$variables['classes_array'][] = 'your-class';
}
}