3

I have a content type that has several vocabularies. Nodes can have 0, 1, 2 or all 3 terms selected.

Ive added a field to the terms so they all have a description as well as their name.

Color (vocabulary)

-Red (term) --This has red items (term description)

-Blue (term) --This has blue items (term description)

-Green (term) --This has green items (term description)

Pattern (vocabulary)

-Stripy (term) --This has stripy items (term description)

-Spotted (term) --This has spotty items (term description)

-Pinstripe (term) --This has pinstriped items (term description)

I have a View of nodes of the content type. I'm using Better Exposed Filters so you can filter by the different terms. I need it so when you have selected a single term its description is shown at the top of the view.

So if you checked 'Red' and 'Stripy', or 'Blue' 'Spotted' and 'Pinstripe', then no description would be shown. But if you just checked 'Blue' then 'This has blue items' would be printed at the top of the view before the nodes tagged with 'Blue' were listed.

  • This sounds like a job for contextual filters and views attachments. – beth Oct 15 '13 at 16:04
  • I cant attach this view to a term page (which is what I think your suggesting) as there are filters based on many different taxonomy vocabularies. – Evanss Oct 16 '13 at 12:49
  • What is preventing it? – beth Oct 17 '13 at 20:52
  • It doenst solve my problem. My view is a single page, its not attached to term pages. Also you can filter with many different vocabularies for a single search. – Evanss Oct 18 '13 at 12:21
  • Can you edit your question to describe how filtering with many vocabularies is seat up? – beth Oct 18 '13 at 14:47
2
+100

Create a template for the view.

Edit the view. Under "Advanced" find "Theme: Information". Click on it to find the names of the templates that are applied in your theme. I think "Display output" is what you want to use. It will show you the contents of the template.

In your custom theme, create a template with the same name as the template you copied. Paste in the contents of the template you copied.

Now you can use PHP to get the information you want (available variables are listed in the comments of the templates), manipulate it as needed, and add it to the $header or wherever you want it, without any PHP in the database.

1

I really don't know if this is the best way to solve this but what I would do in that case is:

  • Add two fields to the view, one for each term description
  • Hide them (exclude from display)
  • Create a new custom field below them (so you could use the fields from (1) as "Replacement Patterns")
  • Re-write the result of the custom field using PHP (Views PHP) checking whether both descriptions are empty or not, to decide when to show or not.

Hope it helps!

  • I guess the solution would be without Views PhP, for security reasons...? – Gregory Kapustin Oct 31 '13 at 13:51
  • The Views PHP exists for a reason. I guess you could even call a function there instead, passing the values to sanitise and validate them before doing anything? – Teknotica Oct 31 '13 at 14:24
0

You might be looking for this:

https://drupal.org/project/taxonomy_tooltip

Using you get description of vocabulary and term description on hovering wherever they appear in content.It automatically add CSS and some effects to term or vocabulary name and shows description of it on hover.

There are lot other options also available you might be interested in. related to tooltip like :

tooltip, field tooltip, views tooltip.

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.