You are here

function social_landing_page_preprocess_field in Open Social 8.5

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()
  2. 8.2 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()
  3. 8.3 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()
  4. 8.4 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()
  5. 8.6 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()
  6. 8.7 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()
  7. 8.8 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()
  8. 10.3.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()
  9. 10.0.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()
  10. 10.1.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()
  11. 10.2.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_field()

Implements hook_preprocess_HOOK().

File

modules/social_features/social_landing_page/social_landing_page.module, line 239
The Social landing page module.

Code

function social_landing_page_preprocess_field(&$variables) {
  if ($variables['field_name'] === 'field_button_link_an' || $variables['field_name'] === 'field_button_link_lu') {
    $entity = $variables['element']['#object'];
    $button_style = $entity->field_button_style->value;
    foreach ($variables['items'] as $key => $value) {
      if (isset($variables['items'][$key]['content'])) {
        $variables['items'][$key]['content']['#options']['attributes'] = [
          'class' => 'btn btn-lg ' . $button_style,
        ];
      }
    }
  }
}