I've got Views 2 installed and working quite well with most things I've tried with it, however over the past day and half I've been trying to simply pass a taxonomy term as an argument in a Views block and failing.
My goal is to simply show content that is related to that taxonomy term the user is on but filtered to only show certain content types, published, and not on the frontpage. The last 3 requirements are easy of course and works just fine.
I've set it up to use an argument of Taxonomy Term and when I run a 'Preview' on a block it works just fine, I enter the name of a Term and it works in the preview. There are no spaces and the term was all lower case in this test. However when I save this and try it on the frontend using the pathauto'd taxonomy term path OR (when I used taxonomy term ID) taxonomy/term/# it would not work. It seems either there is a bug with a Views block not able to read the URL, or there's something I'm missing completely to get this to work properly.
Anyone have any ideas? The articles I've found searching around all say to basically write or use a little php snippet and place it in the "argument handling code" section, however in Views there's only "Default Handling". I'm guessing this is a difference in the versions?
Little help would be appreciated as I'm stumped and starting to think it will be easier to just throw together a module to do the same thing.
Thanks
Comments
For argument "Taxonomy: Term
For argument "Taxonomy: Term Id"
Set "Action to take if argument is not present: " to "Provide default argument"
Under "Default argument type:" select "PHP code", if this option is not available enable the "PHP filter" module.
In the text box (if the path is taxonomy/term/tid) add
return arg(2);Oi I feel stupid, that IS
Oi I feel stupid, that IS simple. I see how to get it the rest of the way to meet what I'm trying to do.
Thanks!
what if the url is something
what if the url is something else and I'm trying to get taxonomy from the node?
You need to provide more
You need to provide more detail on what you are trying to do. For example what is the path?
Subscribing, greetings,
Subscribing, greetings, Martijn
ok but what if path and
ok but what if path and taxonomy are different?
i have taxonomy: Robbie Williams
but path is www.blablabla/robbie-williams
what then?
Is that the real path or an
Is that the real path or an alias? If the real path what is producing the page?
it is alias and i guess i
it is alias
and i guess i need as a argument Taxonomy Term, not the node : tid
but taxonomy term will not match the alias! coz they are different
So what is 'robbie-williams'
So what is 'robbie-williams' an alias for, taxonomy/term/{tid} or something else?
yes
yes
works so well
thank you nevets.
you offer the most straightforward/clear comments.
Hi Sorry for cross-posting. I
Hi
Sorry for cross-posting. I Am also looking for something similar to this.
I want to have term name of my current node and let the view return desired fields from the nodes that share same taxonomy term name. However, the vocabularies are different of the 2 content types.
One node type is - articles with URL Alias - www.ex.com/article-network//
The other node type is - books with URL Alias - www.ex.com/books//
The complication is that both the content types have different vocabularies as article-categories for articles and book-categories for books. But, both the categories have same term names.
Now, I want when the article page is opened it should show the images of the books that share the same term name of the active article page.
I am hitting my head since last week but got no results.
Please guide!
Thanks in Advance!
Found this helpful, but still stuck
I found this helpful article at: http://drupalsn.com/learn-drupal/drupal-questions/question-2650
I am trying to use the last term in the pathauto supplied URL as the argument. My URL is www.mysite.com/communities/area1. If I just type:
it works fine. But I wanted something a little more dynamic, like:
Any suggestions on what I'm doing wrong?
BUMP... i would Love to know
BUMP... i would Love to know the same. thank you!
+1
+1
Wrap the block in PHP...
I think the way to do this is to wrap the call to the view in php that gets the taxonomy from the page, but I'm not quite sure how to extract the bit that I want. This is modified from some code that I use to control showing specific blocks on pages with particular taxonomy terms:
This gives the results:
on a page that has the term "WSBE" which is tid 90. What I want to do is extract just the tid value and pass it to a view that will then display in the block, perhaps using something like:
But it doesn't seem one can use input filters (like the insert view filter here) at the same time as PHP.
Advice welcome. If I figure it out, I'll post here.
Got it working
I describe my solution here: http://drupal.org/node/298810#comment-2002654
I had to use views_embed_view rather than the Insert View filter, and implode to collect the TIDs.
The solution for this over
The solution for this over at
http://drupal.org/node/298810#comment-2002654
Helped me out
This is a solution for a different problem
This is a solution for a different problem. This is the solution to put a related block on a Node page.
We want to put a related block on a taxonomy page that has an alias.
Can't you use as Nevets
Can't you use as Nevets suggested? I have an alias for site.com/taxonomy/term/tid to produce site.com/term-name and using
return arg(2);works fine.My new EasySnoozing, Nursing and BusinessEgghead websites on D7!