D
D
Dmitry Kamyannoy2015-04-19 15:28:51
Drupal
Dmitry Kamyannoy, 2015-04-19 15:28:51

How to set a common class for certain taxonomy term pages?

Good afternoon, I have a question. I would like to create a class for taxonomy pages using the machine name of the dictionary, how to do this, please tell me.
Roughly speaking, for example:
We have a dictionary "cities" and a machine name "cityes" I would like this machine name to become a class for all the terms of this dictionary in the body tag. Thank you very much )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andead, 2015-04-19
@redfieldone

function themename_preprocess_html(&$vars) {
  if (arg(0) == 'taxonomy' && arg(1) == 'term') {
    $term = taxonomy_term_load(arg(2));
    if ($term->vocabulary_machine_name == 'cityes') {
      $vars['classes_array'][] = 'cityes';
    }
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question