There appears to be a number of support requests related to views arguments and taxonomy terms which have hyphens and or spaces.

http://drupal.org/node/140478
http://drupal.org/node/197372
http://drupal.org/node/364912

I have a view which lists posts and has an argument of 'tag' and it works great but there is a problem when a tag has a hyphen and a space in it. For example "my-special tag". No posts tagged with "my-special tag" show up...

I have "transform spaces to dashes" enabled on the argument.

When I look at the term's path it is converted to "my-special-tag" the actual term name is "my-special tag". If I view that taxonomy term page posts tagged with that term show up. But when I try to use that term as a view argument no posts show up.

So in my view:
Terms like these work fine as views arguments:
"my-tag"
"tag"
"my tag"

Terms like this are causing issues:
"my-special tag"

So what needs to be done to get posts to show up when visiting a view with a tag argument that has hyphens and spaces?
http://example.com/view/tag/my-special-tag - no posts show up

Any suggestions appreciated.

Thanks!

Comments

internets’s picture

Any suggestions?

Also tried the taxonomy_redirect module. Thought this would be the solution, I configured it to replace spaces with "-" hyphens and to ignore hyphens within the taxonomy term. When I use the following code to get the taxonomy term path it works, except with taxonomy terms that have hyphens, or hyphens and spaces.

(in my node-node_type.tpl.php)

$term_url = drupal_get_path_alias(taxonomy_term_path($term));

Then place $term_url within an href="" and it works for most tags as a view argument except those with hyphens or hyphens and spaces...

Is there a 'best practice' for using taxonomy term names as a view argument?

Suggestions appreciated.

Thanks

daniel wentsch’s picture

Subscribing. I'm surprised there isn't more attention around this issue - or maybe it's somewhere else?

Update:
FYI: I ended up using Taxonomy Views Integrator (TVI) to override Default Taxonomy Pages. Then I'm using URL aliases for the taxonomy terms (via pathauto) that match my views/argument path.

So it my view path is /test/% then the pathauto settings for the corresponding vocabulary (which is being used as argument) is set to test/[catpath-raw]

Now, when calling an aliased taxonomy URL my view takes it and TVI gives the Term ID as an argument to my view.
This way there are no problems with term names as arguments while I still have nicely aliased URLs.

HXn’s picture

Thank you! I was wracking my brain all day and scouring the forums to try and get this to work. This is exactly what you need to do.

vulfox’s picture

Any news about this? I'm building a system where taxonomy terms are folders and can see a potential failure when end users are choosing the names of folders.

Hacking with 1-2 modules more is not something I would really like to do. Oh well...