I have a view that shows nodes and groups them by their taxonomy term. Is it possible to show less fields for a specific term? For example there are user profiles with names and pictures that are listed, but if they have a specific taxonomy term the picture field shall not be shown.

up vote 1 down vote accepted

These types of problems are often solved by creating another Views display.

  1. Add a Filter to your original Views to only show the results with the terms where you want to show the additional fields.
  2. Then Duplicate this display as Attachment, attach it to the original views display.
  3. Override the Attachment Filters and change the one for the terms - reverse the choices to filter out only the terms where you don't want additional fields
  4. Override the Attachment Fields, remove the ones you don't want.

The Attachment results will display below or above the original results, depending on whether you choose to attach it After or Before.

  • Thank you, now I know what attachment means in views! – 0711master Dec 2 at 1:32
  • I'm glad to help! – prkos Dec 2 at 23:43

Try preprocessing the views field.

Something like this is a good starting place: https://drupal.stackexchange.com/a/36712/80164

Note that if you only need to preprocess a certain field, the function to use is template_preprocess_views_view_field(&$vars):

https://api.drupal.org/api/drupal/core%21modules%21views%21views.theme.inc/function/template_preprocess_views_view_field/8.6.x

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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