Hello,

I am new to the Drupal forum and so i am sorry if i have posted in the wrong category or anything but i know when i was searching to find how to display taxonomy with a view i couldn't really find anything that just used the view and in all the forum posts people where commenting on how it cannot be done just using a view. It had to be done all using templates and php and I'm not too good at the php side of things and after hours of playing around with everything i finally cracked it so i hope this helps.

I was developing a website for a customer and what they wanted was each level of taxonomy to link to the next which i know what you saying Drupal taxonomy does this as standard. My issue was the customer wanted a button as well as the link to the category.

So what they wanted was the first level of taxonomy in the menu on the left hand side of the website so then when you click on the 1st level it displayed the second level in the page and when clicking on the 2nd level took you to the 3rd and so on then to display the products.

So this is how it is done just using a view and 1 php argument!!!!

Step 1

Go to site building and click on views.

Step 2

Create a view and before you save the view if you make sure instead of node being selected if you select term - this will create a taxonomy based view for you.

Step 3

Go to the filters section and click to add a filter, select "Taxonomy Vocabulary" and choose the catalog you wish to display the taxonomy terms for, then click update.

Step 4

Under fields i added 3 fields
-Taxonomy Term ID - If you check the box to "exclude from display" then if you scroll down until you find the field "Thousands separator" there will be a "," you need to remove this then click update.

-Taxonomy Term - you need to check the box that says "Output this field as a link" and you need to add the following tokens "catalog/[tid]" the [tid] token is derived from the Taxonomy term id field and by outputting the taxonomy term as a link and telling it to use this path will link it to its children.

-Global Custom Text (This was to create the text to display my button so this field is completely optional)

If you click on "Output this field as a link" and place in the same path as what you did in the taxonomy term field so the button will take you the same path.

Step 5

Now what you need to do is to add an argument, so if you go to the argument section and add "Taxonomy: Parent term" then what you want to do is provide a default argument, then click on php code and add in the following argument "return arg(1);" then scroll down and click on update.

You don't need to place <?php?> tags around the argument as it is only a single argument. What this argument does is to find the parents children or in other words helps the 1st level of navigation find the 2nd level then the 3rd level etc.

Step 6

Then 1 last field you need is a relationship, so if you go to the relationship section and if you add "Taxonomy:Related Terms" you can level everything standard and just click on update.

Step 7

Then if you go to basic settings then if you click on styles you can display it as a table or grid or however you would like to display your taxonomy terms.

Step 8

Finaly if you add a display of block down the left handside then when you have saved your view go to your blocks and enable the block and thats it!!

So this is it how to display your taxonomy with a view and with a button if you need it, you can add in other stuff as well but I have not got that far yet next i am going to experiment with trying to add in an image and i will update this post if i manage it just hopes this helps someone :)

********** UPDATE **********

To add a image with your taxonomy view if you made sure you have a module called taxonomy image then enable this module then when you go into your taxonomy catalog and edit a term towards the bottom you will now see there is an extra field called term image you must make sure you upload the image here or else it will not display.

Then in your view under the fields section you will now have a field called taxonomy:term image.

Under relationship if you choose do not use a relationship then under ImageCache preset put as default then click update, then if you save your

Comments

nevets’s picture

Note that views comes with a view that once enabled will override the default taxonomy path (taxonomy/term/{tid}) and can also be cloned as a starting point for other views using a different path that list content based on taxonomy term.

Also, please edit you post and pick a better forum, nothing should be added to deprecated forums.

nevets’s picture

Note in Drupal 7, you can add fields to taxonomy terms so taxonomy image would not be required.