Closed (fixed)
Project:
Views (for Drupal 7)
Version:
4.7.x-1.5
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
7 Mar 2007 at 17:19 UTC
Updated:
27 Jan 2012 at 15:18 UTC
Is it possible to "override" the alias of a taxonomy url with views? It works fine when you make the view url something like
taxonomy/term/866
then the default taxonomy display is overridden. But, when you try to make it something like
paint/colors/red
or
paint/colors/$arg
then it doesn't work, it favors the system url alias instead. My system weight is set to 10 for the views module.
Using Drupal 4.7.6 with the latest stable views mod 1.5. I'm just intrigued since you can override urls like "blog" which are set by modules. But actual system aliases seem to be different.
Thanks for any help or thoughts.
Comments
Comment #1
merlinofchaos commentedYou usually can override taxonomy/term -- but it relies on module weight. Views tries to to set its own weight on install (and one of the updates does this) but you might want to check in the database manually.
It's the 'weight' column in the 'system' table. Make sure it's higher than taxonomy's. Views sets it to 10 normally.
Comment #2
chrisschaub commentedThanks for the quick reply. It works fine for straight taxonomy urls like
taxonomy/term/888
but, it doesn't work when you try to override a url alias. Say taxonomy/term/888 has a alias paint/color/red -- you can't override paint/color/red, only the actual path of taxonomy/term/888. Tried clearing cache, setting weight of views is 10, taxonomy is 0. Disable all taxonomy modules except taxonomy.
Any thoughts are greatly appreciated.
Comment #3
(not verified) commentedComment #4
reecex commentedI'm having the same difficulty, i need to be able to override url aliases in drupal 5.1,
for example if i set the views url to
taxonomy/term/
and argument to
term ID
the view works normally, how ever if i try to then set my url in views to the alias of that term eg.
meal/breakfast/
with same argument
it wont use the view and reverts to the system default. Which to me makes it seem like the url-alias has a higher priority than the view, ive checked weighting on paths and taxonomy modules etc.. in the system table in mysql , but that is not the the issue.
The only reason i need to do this is because i want to theme my taxonomy/term views differently for certain vocabularies, ie. have different header, footer information and slight style changes in css, which i can not achieve by just using the default taxonomy/term i need to alias the terms and apply "views" to the aliases. If there is a workaround for my problem id be greatly appreciative as to a shove in the right direction.
Comment #5
merlinofchaos commentedUnfortunately, due to the way Drupal works, aliases cannot be overridden. They are processed at a low level, long before Views ever learns about the URL. The only way to 'override' an alias is to re-point the alias somewhere else. Views can't do that for you.
Comment #6
rudins commentedSo...
Edit Argument handling code in that view:
and define view URL, for example: $arg/your_view_url or your_view_url/$arg
Than in your theme use term url alias instead of $arg.
Thats it.
Comment #7
gemini commentedThis is a great snippet! I used different implementation - substitution of hyphens for spaces in multi-word terms, since regular taxonomy looks like /category/term+one/term+two, so getting it to /category/term-one/term-two wasn't a big of a deal. But it creates additional work when special characters come into play like another hyphens and '&' symbols etc. That's why your approach is much better. The only problem with it - I don't see how it overrides the term alias which happens way before the views.
Let's say I have a view with the URL "category". It should render data with arguments like "category/term-one/term-two".
I also have a vocabulary with pathauto set to "category/[term]".
Assuming that your code works as we wish - the views should kick in on any argument withing the path of "category/". Instead, alias kicks in earlier and triggers default "taxonomy/term" view, which (in my case) themed completely differently from the "category" view and serves completely different purpose. If your snippet worked as we wish, all the tags throughout the site including breadcrumbs would work beautifully. The only way your code works for me is when I create pathauto pattern like "xxx/[term]" and then replace "xxx" with the "category" in the template, but it doesn't keep me safe throughout the site and breadcrumbs is an additional work around.
Please, tell me I'm wrong, because I really would like to use aliases exactly as my view usl + argument. If I am wrong - could you please explain how to get to that point when it actually works the way I want?
Thanks a lot!
Comment #8
summit commentedSubscribing. Greetings, Martijn
Comment #9
lupus78 commentedI have the same problem as gemini, but can't find the solution.
How can I override tht default taxonomy/term with my own view, when url alias is set up!?
Comment #10
Coldice4678 commentedI had the same problem, but I came up with a solution:
1st the problem, similar to everyones problem, I had pathauto making index aliases for me, but some levels down, I want to re sort the data using a view, but the url would continue to go to pathauto even if I deleted it, pathauto would reinstate it when I created a new node.
Solution> I made the system url = the url alias Ex. fl/gainesville = fl/gainesville
(problem- when I type the url with a capital G, the browser would have redirect issues)
Solution to the solution> make the system url = the capialize alias Ex. fl/gainesville = fl/Gainesville
(no problem with capitalizing any letter now)
Note: my views url is fl/$arg, pathauto for a node province/city/nodetitle/nid
Comment #11
merilainen commentedIs there any general solution to this problem?
I have a problem with User Profiles: Users can tag their user profiles and I would like to show a list of other users when they click any tag in someones profile. But because users are tagging their profiles, clicking a term shows a list of the profiles. I have created a view which shows the table of the authors of these profiles but I cannot set it as default view. The view works when I set the URL to some other than category/something.
Comment #12
aviddv1 commentedNot sure if this is still an issue for anyone, but in Views 2 you can create a page and use taxonomy/term/% for the path, where the argument % is the term id. If you're using url aliases so that category/something/termname = taxonomy/term/2 then when you go to the alias, the view will automatically override the normal output of category/something/termname and display the view you created.
My issue was wanting to reformat the term results as a grid and relying on the Views module to do so. I wanted to leverage the taxonomy paths straight from the alias instead of creating my own paths and having the alias paths still be active. If a user visits the alias path (category/something/termname) they would see the content as a list. Using Views, the alias path is intercepted and the resulting page is the Views page as a grid (in my case) instead of the default list display.
This also means that while the default is to display individual nodes, Views will let you display fields which means more control over the individual field output.
hope this makes some sense. makes me think Views should be a part of drupal core.
Ward
Comment #13
totocol commentedWell at least when it is with users, instead of using UserId as argument just use user:Name which is what is used in the URL. I am not sure if that Argument category is also available on Drupal 5 but it is on Drupal 6. It would work the same with Taxonomies I guess.
Comment #14
pjsz commented#12 aviddv1, Thank you. That is exactly what i needed to do and was struggling. I was doing it backwards. You saved me a great deal of time with that tip. Cheers.
Comment #15
spookypld commentedthx addiv !!! :)) this saved a lot of my time
Comment #16
wakeuphate commentedComment #17
nocean commentedThanks aviddv1! That worked perfectly.
Comment #18
Marko B commentedthis should be used now
http://drupal.org/project/views_tpo
Comment #19
Sifro commentedIn D7 i achieved this by modifying the drupal_get_path_alias()... if someone is intersted i can write a little how-to of the workaround i found.
Comment #20
summit commentedHi Simone, Yes please!
Greetings, Martijn
Comment #21
Sifro commentedThere are 2 possibilities.
1) nice and clean (suggested by nevets here: http://drupal.org/node/1296576): If you use the taxonomy view that comes with views (it over rides the default taxonomy/term/{tid} path) and use pathauto to create your path alias things should work without any need to override paths.
I tested it and it works. But there are some things that i couldn't manage to customize with this solution (like custom titles\urls)... so, there is solution #2
2) this is pretty horrible, but it works.
- Give to all your taxonomy terms an alias like this: category-someWeirdSuffixHere/name.
- Create a view with an alias like this: category/%
- Then, locate the drupal_get_path_alias() function in includes/path.inc and add these lines before the final return:
if(strpos($result,'-someWeirdSuffixHere'))
return str_replace('-someWeirdSuffixHere','',$result);
- You can also create a totally different alias for a taxonomy term, for example:
if($result == 'category/blue') return 'my-blue-stuff';
After adding this line, you just have to create the corresponding customized view with 'my-blue-stuff' as URL. (this is one of the things that i couldn't mange to do with solution #1).
Would love to switch from #2 to #1, tough.
Comment #22
dubs commentedThe other possibility which works really well is this module: -
http://drupal.org/project/taxonomy_display