Hello,

I'm setting up a views argument to display various photos in a view based on the taxonomy term(s) selected in the node. However, it seems to me that before I can do this I need to get my Pathauto settings in place.

So I was looking at /admin/build/path/pathauto, and had a couple questions:

  • There is both "Node path settings" and "Taxonomy term path settings". I already have the "Node path settings" for that content type like this: photos/[title-raw] . So I'm not sure where I should alter this (and what the difference is between the two settings types in general).
  • Also, how should I enter the tokens to work best with the view's argument? I just need something simple in the URL like /photos/flowers/title. But with all the available replacement patterns etc., I'm not sure exactly which to use.

Once I get this down, there is a lot of info. about the views side of the argument setup. But I haven't found any info. about how to (best) set up the Pathauto side of this. Any advice will be greatly appreciated!

Jim

Comments

mr.baileys’s picture

Status: Active » Fixed

I'm setting up a views argument to display various photos in a view based on the taxonomy term(s) selected in the node. However, it seems to me that before I can do this I need to get my Pathauto settings in place.

Views takes its arguments from the actual path, not the alias. If you alias "taxonomy/term/4" as "fruit/banana" and tell views to take the second element from the path as argument, it'll use "term" and not "banana". Because of this, you can just start building the view and worry about pathauto later.

There is both "Node path settings" and "Taxonomy term path settings". I already have the "Node path settings" for that content type like this: photos/[title-raw] . So I'm not sure where I should alter this (and what the difference is between the two settings types in general).

In short, node path settings will set up aliases for URLs of the form "node/<nid>", and taxonomy term path settings will set up aliases for URLs like "taxonomy/term/<tid>".

If your individual images are nodes, you would set up an alias of "photos/flowers/[title-raw]" to point to nodes of content type image. You would set up an alias like "flowers/[vocab-raw]/[cat-raw]" to point to taxonomy/term/<tid>. When someone then browses to flowers/color/red, pathauto changes the path to taxonomy/term/7 (with 7 being the <tid> for color: red).

Now, suppose you want to set up a views page to display all flowers of a certain color. There's a couple of ways to do this:

With pathauto:

  • Set up an alias "flowers/[vocab-raw]/[cat-raw]" for taxonomy term paths
  • Set up a views page for "nodes", use "taxonomy/term/%" as path for the view (this will actually override the default path for terms)
  • Set up an argument of type "Taxonomy: Term TID"
  • Configure the rest of the view

Browse to flowers/color/green ==> pathauto replaces this with taxonomy/term/4 ==> views captures the request for taxonomy/term/4 and uses 4 as taxonomy term argument.

Without pathauto:

  • Set up a views page for "nodes", use "flowers/color/%" as path for the view
  • Set up an argument of type "Taxonomy: Term" (telling Views that it'll receive the name of the term as argument, not the id)
  • Configure the rest of the view

Browse to flowers/color/green ==> views captures the request for flowers/color/% and uses "green" as taxonomy term (name) argument.

Also, how should I enter the tokens to work best with the view's argument? I just need something simple in the URL like /photos/flowers/title. But with all the available replacement patterns etc., I'm not sure exactly which to use.

See higher up: Views doesn't really care about the alias since it uses the system path.

Hope I didn't confuse you even more...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

greta_drupal’s picture

@mr.baileys : Thank you for taking the time to compose such a thoughtful (detailed) response. Came across this post in search for an issue and this might have just given me new ideas. You rock!

soundboy89’s picture

This is exactly what I'm trying to achieve -- with one extra bit: I'd like to display the title of my view page using the URL alias.

Using the example Mr. Bailey's gave, the flowers/color/green would correctly point to the original path to take the argument, taxonomy/term/4. But then I'd like that page to have the title "Photos: green" using that taxonomy term in the title. Since I'm in views, I only have the term ID (4) available, but not the name of that term to be able to display it in my title.

How can this be done?

* * *

Edit: I just found out that Views does this automatically if I set my Title Argument simply to %1, it'll take the ID and substitute it for the name. Awesome! (I'm using users as arguments in my case instead of taxonomy, so I'm not sure if it would work the same way).

AmirKa’s picture

@mr.baileys
Thanks for the detailed explanation. I was searching the web as I had confusion about path alias and Views and you cleared that nicely.
Thanks again for taking the time to write such a clear and to the point post.

"من لم يشكر المخلوق لم يشكر الخالق"