You are here

function paragraphs_id_preprocess in Paragraphs ID 7

Implements hook_preprocess().

Add class with paragraph item entity id to paragraphs item.

File

./paragraphs_id.module, line 51
Paragraphs ID module file.

Code

function paragraphs_id_preprocess(&$variables, $hook) {

  // Only run with paragraphs_item entity.
  if (!empty($variables['entity_type']) == PI_PARAGRAPH_TYPE) {
    if (!empty($variables[PI_PARAGRAPH_TYPE])) {

      // Get paragraph entity.
      $entity = $variables[PI_PARAGRAPH_TYPE];

      // Get the paragraphs item id prefix.
      $id_prefix = paragraphs_id_get_prefix();

      // Define class name.
      $class = $id_prefix . $entity->item_id;

      // Add class to classes_array.
      $variables['classes_array'][] = drupal_html_class($class);
    }
  }
}