4

I created a view which has an exposed filter for taxonomy terms. Now the next step is to theme the options. I tried the module "Better exposed Filters" but I wasn't satisfied. I would like to have images to click on instead the standard filter. I already have stored the images in the taxonomy fields, so every term has it own image.

I tried to create a template file for the filter, but I don't have any access to the fields, where the image is stored. I could do some hardcoded stuff, but I want it as generic as possible.

Has anyone an idea how to achieve it?

  • Welcome to Drupal Answers. I'm not aware of any module that fulfills your need, so you will probably have to do some (more or less advanced) coding. It would maybe help to know your coding skills. In general this site is not intended to provide ready made solutions, but to help you find the right way, so it would be helpful to know what you have already tried and which ressources you have consulted (if any). – berliner Feb 21 '14 at 0:17
  • Hey, thanks for your response. I don't a completed solution :/. I updated my original post which what I have done so far. My coding skills in general are decent in php and js – Leagis Feb 21 '14 at 8:47
0

Use "Better exposed Filters" and choose its Display setting as Checkbox
Now you have to do form alter like this

function THEMENAME_form_views_exposed_form_alter(&$form, &$form_state) {
  foreach ($form['TAXONOMY_ELEMENT']['#options'] as $tid => &$name) {
      $term = taxonomy_term_load($tid);
      $name = '<img src="' . file_create_url($term->IMAGE_FIELD_NAME['und'][0]['uri']) . '" />';
  }
}

In my case ::
TAXONOMY_ELEMENT = field_type_tid
IMAGE_FIELD_NAME = field_term_image

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.