1

Trying to set up a preprocess_field_hook() to send a different css style depending on the node that is loaded for simpler theming. Will not work and been beating my head.

Have this set inside my template.phpand have my tpl pages named correctly (exam: node--node_page_one.tpl.php), which is loading fine with other functions already working. I feel like I need to have it point to the actual element somehow? Or should I be doing this somewhere else like in the preprocess_node_hook()?

Sorry for my noobness.

 function mytheme_preprocess_field(&$variables, $hook) {
      $variables['fieldclass'] = '';
      switch ($variables) {
        case 'node_page_one':
          $variables['fieldclass'] = 'tiny-blue';
          break;
        case 'node_page_two':
          $variables['fieldclass'] = 'large-green';
          break;
        default:
          $variables['fieldclass'] = 'black';
          break;
      }

1 Answer 1

0

Rather than $variables['fieldclass'] use $variables['classes_array']

Based on the docs

1
  • After taking this into account and tinkering with what I had. Got it working! ($vars['element']['#bundle']) For future theming, what is the best/easiest method to discovering the classes array? Thanks again for the help!
    – tdm
    Commented Sep 16, 2013 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.