0

I'm not sure if I have understood correctly how views override taxonomy page. What I would like to do is to let taxonomy page have two arguments and each of them are taxonomy terms from different vocabularies. For example, I have two vocabularies and like below. Node can be tagged with multiple terms from but just with one term from

<Color>
 Blue
 Red
 Grey

<Car>
 GM
 BMW
 Toyota

I would like to make URLs like this.

/Blue/GM
/Blue/BMW
/Blue/Toyota
/Red /GM
/Red /BMW
/Red /Toyota
/Grey/GM
/Grey/BMW
/Grey/Toyota

And when user taxonomy link on node page view for example, If the node is tagged with "Blue" "Red" "GM"

Click "Blue" takes to /Blue/GM
Click "Red" takes to /Red/GM
Click "GM"  takes to all the node list of "GM" maybe URL /GM

I've been playing with taxonomy views but still can't figure out hot to achieve this.

0

Based upon my read of your question there may be several things to address here.

  1. View is not overriding your URL. The address you have in the URL should be unique and intended to call the view just as if it is any other piece of content. Do not have more than one piece of content with the same address, can only confuse things. Ignoring aliases for a moment, that means you cannot create a view with the path of taxonomy/term/tid, but you can create one called taxonomy/term/tid/facts. adding the fourth level of the URL makes it a unique address.
  2. You are not defining a taxonomy page with terms from two vocabularies. To provide the content you desire you should create a view with the desired URL name.
  3. A taxonomy page has a URL of taxonomy/term/tid. You can provide it with an alias, but that can confuse your thinking. The first thing Drupal always does with an alias is convert it back to the original path. So anything that uses the URL, such as Views will not see the alias, it only sees the original path. That means that that if the paths you desire, such as red/gm are aliases, they will not be seen by the view.
  4. A view can have multiple paths using the % wildcard. If you created a view with a path of /cars/%/brand Then your view will be called by Drupal for any value placed in the % location of the path.
  5. A view path should always have a static name for the first and last positions of the path. In your examples above for red/GM you basically have an URL of %/%which would be assigned to just about everything.

To create your desired View content you may want to try the following:

  • Define two vocabularies for brand and color, and/or anything else you want in the categorization.
  • Create a content type that includes fields for these two vocabularies and give the content URLS following the formula similar to `cars/%(color)/%(brand)/
  • Create a view with a path something like cars/%/%/view The word 'view, in the path can be anything you desire.
  • Define the view to display whatever content you want.
  • Create two contextual filters, the first defined to read a term from the color taxonomy and the second to read the brand. Views will use the value of the first % for the first contextual filter and the second % for the second filter.

That should get you started, although I suspect you will have at least one more round of questions before it works for you (It always does.) There are a lot of previous questions on this site whose answers will help solve the details for you. There is also an excellent video series 'Taming the Beast' that can show you everything you need to know about views.

  • 1
    Thank you very much for your detailed explanation. It took me some time to understand and get used to how Views works. Yes, please let me have another round of the question. I actually made a view with a path just cars/%/%/ without the static name at the last position and it seems to be working. I understand that the one at the first position is necessary but the one at the last position can not be omitted? The second question is that will it be ok to have alias for example like this? Blue=cars/tid(color) and GM=tid(brand)/view So the URL will be Blue/GM from cars/tid(color)/tid(brand)/view. – chinita7 Mar 4 '12 at 19:23
  • Yes cars/%/% will work. If you have more than one page defined in the View, you will need the static end name to distinguish between them. I have gotten into the habit of always providing a static ending by default. Be careful that you do not have any duplicate path names both in Views and in any other site path such as a node. – Ashlar Mar 5 '12 at 14:30
  • @chinita7: Your second question is actually a different one. Please ask it separately so others can see the question and answer in the future. (Comments are not tagged and searched like questions are). Thanks. – Ashlar Mar 5 '12 at 14:32
  • that was very helpful. Now I can feel my knowledge about Views is much wider than last week :) Thanks! – chinita7 Mar 5 '12 at 15:27

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.