Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I create a cck type with a field-collection field, the collection field contains a taxonomy term.
When I open the taxonomy term, no node is displayed, this message is displayed :There is currently no content classified with this term.
Comments
Comment #1
craigmc CreditAttribution: craigmc commentedSubscribing-- also seeing this behavior.
Content Type:
my_node_type
has an unlimited field-collection: my_field_collection
My_field_collection has a taxonomy term reference: my_term_ref
I create a new my_node_type and set a value for my_field_collection of Taxonomy_Term_1
When I go to the taxonomy/term page for Taxonomy_Term_!, I get "There is currently no content classified with this term".
Comment #2
odegard CreditAttribution: odegard commentedI've just starting looking into this module so my advice/understanding might be way off.
My impression is that this module works sortof like a node reference, but referencing a collection of fields, not a node per se. In D7, content types are nothing BUT a collection of fields, so perhaps this module could, instead of defining it's own "content type" aka collection of fields, use an existing content type as fieldable entity in the main content type...?
ANYWAY, to solve your particular problem, I think you'd have to make your own tax/term views. Make a page taking term as argument. Then add the field collection as a reference, then pass the argument to the term in the collection...
You should think of the term ref field inside the field collection as a term field for that particular field collection instance, not automatically belonging to the node where the field collection is added!
I hope that made some sense.
This is a module with very high potential!
Comment #3
hbellahc CreditAttribution: hbellahc commentedHello
When you say : Then add the field collection as a reference
What it means please ?
Thanks in advance
Comment #4
odegard CreditAttribution: odegard commentedSorry, I meant "relation". In views, click on advanced, relations and add the field name for the collectible field. This will "open up" the terms belonging to the collectible fields field in the content type.
Not sure exactly how to proceed from here. I would probably use the page manager in ctools to get the term in the url as a context and passing it to the view like that.
Comment #5
Jessica A CreditAttribution: Jessica A commentedsubscribing
Comment #6
Tony Finlay CreditAttribution: Tony Finlay commentedI've managed to get this working using views, if anyone wants to know how let me know here and I will write a tutorial, I am following this issue so will check regularly.
Comment #7
Jessica A CreditAttribution: Jessica A commentedIf you could write a tutorial on how to accomplish this in views, that would be greatly appreciated!!
Comment #8
blenny CreditAttribution: blenny commentedThis is because there is no content tagged with the term, therefore no content will be displayed on the term page. But i'm somewhat confused about what you're trying to do.
Comment #9
craigmc CreditAttribution: craigmc commentedall, the issue is that the taxonomy term relations from the field collection are not inherited back to the node that contains the field collection. Maybe this is by design, but I would imagine that if a given field collection (entity) were tagged with a given term, you would see something appear on the taxonomy/term page-- at least the field collection, if not the node that refers to it.
Take the analogy of a node reference. If the referenced node is tagged with a specific term, then the referenced node will appear in the /taxonomy/term page for that term. One would expect similar behavior from the referenced entity.
Ideally, since this module logically functions like the Multigroup CCK module from 6.x-3.x, we'd expect that if there are terms applied in the multigroup/field-collection, that they would apply to the containing node, hence why this issue is posted.
As for ways to solve this using Views, etc. Thanks for the offer. That may well be a work-around to achieve the desired result, but to my understanding of taxonomy, we at least should get the field-collection entity at taxonomy/term, if not the node itself. (Ideally the node itself).
Comment #10
aendra CreditAttribution: aendra commentedAny updates on this? Or even better, any idea how to find a host-entity's NID given a particular taxonomy term attached within a field collection, whether as code or via Views?
I'm using field collection to do advanced author meta data and multiple authors, and am trying to create a page for each author showing which articles they've contributed to. Any help?
Thanks!
Comment #11
Tony Finlay CreditAttribution: Tony Finlay commentedThis module now has a 7 dev release; http://drupal.org/project/taxonomy_image. I haven't tried it yet but it seems to have the functionality I was originally looking for.
Hopefully it's of some use to the others in here
Comment #12
aendra CreditAttribution: aendra commentedIf it helps, I figured the easiest way to accomplish this was by accessing the SQL tables directly, and unhooking the taxonomy links associated with the vocabulary in question. Example below to list articles when taxonomy field named "field_byline_author" is within a field collection named "field_bylines".
Hope this helps someone -- I was scratching my head pretty furiously for awhile about how to manage this.
Comment #13
aendra CreditAttribution: aendra commentedSo, that moment when you spend several hours coding something, before realizing you actually *can* do what you're wanting to do in Views, in under ten minutes?
Using the example above (unlimited value field collection named "field_bylines" containing a taxonomy field "field_author" and text field "field_position"), you can accomplish pretty much the exact same thing by creating the following view:
1. Create a view, call it whatever you want. Make path something like "author/%"
2. Click Advanced, Add a Relationship. Choose your field collection; in this case, "Content: Bylines"
3. Add a Contextual Filter. This will be the taxonomy field (I.e., "field_author"), should appear named something like: "(field collection item from field_bylines) Field collection item: Author". Tell it not to display anything when filter value is not in the URL.
Tah-dah. Should work. If you want your field collection listed in the results instead of the default user creating the content:
4. Under Format, click "Content". Change to "Fields".
5. Under Fields, Click Add and select "Content: Bylines". Change formatter to "Fields Only" and uncheck "Create a label". (Last two are my preference to tidy UI up)
Note that you'll have to supply the author's term id to the view instead of the term name (I've never figured how to supply a term name as an argument as opposed to a tid...).
Comment #14
kalman.hosszu CreditAttribution: kalman.hosszu commentedI set the issue's properties.
Comment #15
tim.plunkettI believe this is a duplicate of #1131872: Fieldcollection items that have a taxonomy field assigned and a term given are not shown on the corresponding taxonomy page
Comment #16
Frippuz CreditAttribution: Frippuz commentedActually, I don't think doing this by code isn't a bad idea - if you want to support several fields at once.
The web I'm working on has 30+ fields with different vocabularies, and it wouldn't be feasible to add a view for each field.
I've made something similar split into two parts; one coded, and a quite simple view.
Part 1:2 - function to get the nids
Function to get the nids I want to get information from:
I guess I need to to something about those queries to make them secure, but the function works.
Due to the fact the function is pretty heavy, it also incorporates simple caching. I've added a clear cache in a hook_node_insert() function, but I think I need to rethink that when it clears the cache a bit too often.
Part 2:2 - Views
To use this, I've created a view with a contextual filter in views. It's a nid filter set as a default PHP value :
The filter is also set to allow multiple values.
The rest of the view is pretty straight forward. I'm using a panel display with a few fields and a exposed filter to handle the results. The panel is then placed into a custom page. I guess a views page would work as well.
I hope this can be of use to someone else.