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';
        case 'node_page_two':
          $variables['fieldclass'] = 'large-green';
          $variables['fieldclass'] = 'black';

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

Based on the docs

| improve this answer | |
  • 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 Sep 16 '13 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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