I'm creating a list of taxonomy terms for a given day and am wanting it to display a list of terms with links to their respective pages. I basically have this working with the exception of a minor annoyance...
If one of the terms appearing in the list has a parent term, the pathauto link for the child term isn't being output properly from views.
Example:
I have a term, Sports, which has a child term of NBA. Based upon my Pathauto the URL for this would be mydrupal.com/sports/nba and this link works just fine. However, the link Views wants to assign it is mydrupal.com/nba, completely omitting the parent term. This leaves me with broken links and my views terms links not matching up with my pathauto.
My view is setup as follows:
Style: Unformatted
Arguments: Taxonomy: Term ID (Summary ascending if no value, which is going to be this views primary view) as List
Fields: Taxonomy: Term
As stated, it generates my list and everything just fine with the exception of parent terms in the pathauto URL.
Just to note... Another view I have constructed which returns all terms associated with a node actually returns the CORRECT pathauto for the situation described above.
Am I doing something wrong or have I run into a limitation of Views itself?
Comments
Comment #1
dawehnersry i'm not sure what you are trying to do, could you please export the view, this would be nice
Comment #2
fawkstrot commentedThe view is below.
The problem I'm having is that links for the terms are generated improperly in accordance to the pathauto URL. If the term has no parent, it links to the pathauto URL just fine. However, if the term has a parent, Views isn't linking it to the correct path.
Example:
I have a term named "Sports". I also have a term named "NBA", which is a child term of "Sports". Views will link "Sports" properly to its pathauto URL which is mysite.com/tags/sports. Views will NOT link "NBA" properly to it's pathauto URL which is mysite.com/tags/sports/nba, instead it tries to link to mysite.com/tags/nba, which is not a URL that even exists in the system (which makes me wonder how Views is even generating that in the first place, since it doesn't exist anywhere, even in pathauto).
I have tried this in all sorts of various configurations without much luck. What is peculiar is that when you generate a list via an alternative method, like a specific Node (Nid in Views) and then do a "Taxonomy: All terms" in the fields, it will generate the links just fine, even to categories with parent terms. Eh?
View:
Thanks in advance for any help.
Comment #3
dawehnerthe problem about this is that views does just use the drupal built in functions
can you disable the path aliases and check whether the urls are generated the right way?
Comment #4
fawkstrot commentedIf Views just uses Drupal built in functions then why does the "Taxonomy: All terms" field display the URL's correctly? Obviously Views is pulling this value from somewhere.
Also, even in my broken list, it's still using the path alias term name to construct the URL, it's just omitting the parent.
It seems to me that Views is interacting with it somehow?
Comment #5
merlinofchaos commentedOk, the problem here is a fundamental misunderstanding in what path aliasing does and how it interacts with Views.
First, you can't turn off aliasing, all you can do is disable the automatic aliasing and the UI for manual aliasing. The data will remain in the url_alias table, and will still be used by Drupal unless you truncate that table. I would NOT advise truncating that table unless you've got a backup, as it will break a lot of links to your site.
Secondly, each alias is a very specific alias for a very specific URL. In the case of taxonomy, what you get is this:
Assuming the TID, or taxonomy term identifier for sports is 1 and NBA is 2:
sportsbecomes an alias to the pathtaxonomy/term/1sports/nbabecomes an alias to the pathtaxonomy/term/2Now, your view is using the taxonomy argument. This means that unless you're a view at the path taxonomy/term/%term (and using the numeric tid argument) pathauto's aliasing has absolutely no effect on the view. Instead, you get:
tags/sportsandtags/nba. And just because you have a view that uses a taxonomy term name argument does not mean that Drupal considers that "the" URL for that term. It will still be taxonomy/term/1 which has the alias of sports.Now, here's where things get tricky. If you change the alias to
tags/sportsand visit it, internally, Drupal will seetaxonomy/term/1, nottags/sports. Which means your view of with the pathtagswon't handle it at all. You need to use the taxonomy_term view which has a path oftaxonomy/term/%in order to see it.Whatever it is you want to do, there is no way to get an arbitrary view to use the pathauto generated aliases. Those aliases are specific to the path at taxonomy/term/TID.
Comment #6
fawkstrot commentedI think I understand most of what you said correctly.
A quick follow up...
In my URL aliases, pathatuo has created them as such:
Are you saying that within views, with the term set to link to taxonomy term page, there's no way to get views to know that link is sports/nba? All I'm trying to do is link to the term page, and the URL alias does exist, it's not based off of a dynamic view.
I think the main thing confusing me is that I have another view which displays all terms based off of a NID, and it renders all of those taxonomy links with the pathauto aliases just fine (with the parent term in the url, i.e. sports/nba).
I hope I'm not being a pain :P.
Comment #7
merlinofchaos commentedIf views creates the link taxonomy/term/13 then Drupal will render that as sports/nba which is why when you list terms, it gets the right aliased URL. Views won't actually ever know that this happened.