By jdelaune on
Is there a way I can assign a taxonomy term to a Views display (page). Or maybe set a taxonomy depending on the path?
I.e. all nodes with the path /fruits/oranges/* gets assigned the taxonomy oranges?
Is there a way I can assign a taxonomy term to a Views display (page). Or maybe set a taxonomy depending on the path?
I.e. all nodes with the path /fruits/oranges/* gets assigned the taxonomy oranges?
Comments
What are you trying to
What are you trying to achieve? Taxonomy terms are assigned/associated with nodes.
I know, but when you create a
I know, but when you create a view which is a page display then it effectively is like a dynamic node.
Basically bits of the site gets loaded in depending on the terms, which is great in most cases when it's just nodes, but there are few places where I need it to happen on views as well.
In the past I've just used embedded views but I now need to do a view which takes in arguments from the url, but if you put arguments on the end of a node url it tries to find an alias for that rather than treating them as arguments.
Ok, what are we talking about
Ok, what are we talking about here, a view or node? They are different things.
If about views, you can make a view that takes arguments and add a page display.
Well, here's an example of
Well, here's an example of the problem from another perspective.
Say I create a a taxonomy vocab like 'section' or 'department' to load some extra data or change the appearance of nodes. I use pathauto to create a URL for the node based on the section, a view to output the section name in a block, and jQuery to change the appearance of the block based on the section name printed in the block. But this method doesn't work if the URL points to content served by a view [page] -- IE, my view that pulls the section name obviously can't pull a taxonomy tag if the source is a view.
So in my case, using taxonomy for section won't work on a view because taxonomy only applies to nodes. In my case I'll need to do something else for views, like go into the template layer and use some PHP to filter on the URL, which contains the section name.
I don't know how to do it, but maybe if you need to do some minor categorization of views like I've described, you could use the administrative tags for a view. I haven't looked but probably the views API offers access to those tags.
So I believe the message here is you'll need to find another way to categorize and filter against views.
=-=
It isn't effectively a node. it's a view, with a page display stored in a views table, not in a node table unless it's embedded into a node.
Assigning a taxonomy to a view page (calendar)
Just sharing something I figured out.... may or may not be the correct way, but it works. All of the searches I found said that we cannot assign taxonomy to a view, which seems to not be the case (I am new to Drupal so I may be off on this). The problem I was having was that I embedded the calendar page view on a node so that I could assign taxonomy and have nice bread crumbs. Once you use the navigation to go to the next month/week/day, etc. the page path is suffixed by the date (and you lose your taxonomy and bread crumbs). I have my taxonomy terms redirecting to certain pages and I was still able to use the following method:
Example: Your taxonomy is as follows:
1
-2
--3
Now when I go to my view page, I see breadcrumb links to Term ID 1>Term ID 2 (to their correct path alias). Hopes this helps someone in the future.
Try a Better Clarification
I have a more simple use case.
I have a page view for our FAQs. We'll call this View 1.
I have a different block view which lists all the pages that have to do with a certain topic using Taxonomy. We'll call this View 2.
I use a module to make View 2 show up on all the pages which are associated with that topic.
View 2 will not show up on the FAQ page (View 1) because there is no way to assign taxonomy to that Page. What's worse is that View 1 will not even show up as a part of the list of pages in View 2 either.
So what I have to do is use my Redirect content type in order to create a piece of content which will show up in the list, yet redirect to View 1 and I also have to set a specific Context in order for View 2 to show up on View 1.
It would save a lot of hassle if Views Pages could be assigned Taxonomy like a Node and were treated as Nodes in the eyes of the Views module in some contexts.
I hope that's clearer.
Note that the FAQ Module explodes when you try embedding it on a page and, to be honest, embedding the view on a page seems a little wonky, don't you think?
=-=
not much has changed in the past three years. views aren't treated as nodes (you can't add form fields to a view) and you can't directly assign a taxonomy term to them without embedding into a node where form fields are made available.
_
in all honesty, it sounds likes you're doing something incorrectly here. Views are not nodes and they are not meant to be nodes so they will never behave as nodes. Views are lists, period. The module enhances them with all sorts of amazing functionality (like being able to assign them a url), but at the end of the day they're always just lists. And all efforts to use them differently usually end up in frustration and the kind of hack you describe.
My guess is there's a better 'drupal' way to do what you want, but without knowing the details of the use case you're trying to address it's impossible to make a suggestion.
Just realize that nearly every time you find yourself fighting to do something a certain way it's very likely because 1) you're doing things in a way it's not meant to be done and 2) there's very likely a better, easier, drupal, way to do it. At least that's been true for me every time I find myself in this position.
Just Change the Gravitational Constant of the Universe
Thanks for responding to my post. I don't think the problem is with us not understanding how the universe works... I definitely understand the responses to the O.P., but why it can't work differently for what we want to do.
I'll try to find Q. I'm sure he'll have this fixed in a jiffy. :)
=-=
Good luck. The only way I could see this happening (views maintainers aren't likely to do it) is to generate a submodule that would output (wrap) a view into a node/entity which is essentially embedding it.
Digging through contrib also uncovers: https://www.drupal.org/project/views_field_view which allows a view to be pulled into a node via a field.
Sounds Tough
Yeah. There are two components to this... a way of assigning Taxonomy to a Page View and a way of inserting Page Views into Views. Considering the fields of a Page View are completely different from Nodes, this sounds like quite a daunting task indeed. However, I could see it not being too terrible if you're only interested in using the Display Title and URL of the Page View in a list.
For it to be full-featured would be an unworthy hardship, I think.
I'll put some thought into it. Might be a nice future project.