I create a content type with a "field collection" field. Then I configured this "field collection" field to consist of a "Title", an "Image" and a "Taxonomy" field. Then I created a node of the new content type. I added a few "Field collection" items, gave each of them some Taxonomy terms.
When I now go to taxonomy/term/2 I get an empty page and the text "There is currently no content classified with this term."
But when I look at my node I see the added "field collection" items and the Terms they have.
Expected Behavior: "field collection" items that have Taxonomy Terms applied should show up on the corresponding taxonomy listing
Comment | File | Size | Author |
---|---|---|---|
#8 | copy_tags.txt | 854 bytes | oda |
Comments
Comment #1
kaplingat CreditAttribution: kaplingat commentedI too am facing this issue. It seems taxonomy field in a field collection entity is not getting associated with the node entity which contains the collection entity.
Comment #2
RobW CreditAttribution: RobW commentedSince field collections' child fields are not really embedded in the $node object, this makes sense. A field collection field contains only a entity uri used to reference the content / child fields of a field collection entity. So the node itself does not actually contain any of the field collection's taxonomy fields, and the taxonomy listing is probably filtering for only nodes, not module-provided entities.
If #1047784: [Meta] Views Integration for field collection is settled you would be able to get this functionality with views relationships.
Comment #3
fagoThis is - by design - of drupal core. Core taxonomy only lists nodes there, nothing field-collection can do about.
Views might be certainly a way out.
Comment #4
Jessica A CreditAttribution: Jessica A commentedAnyone know how to get this functionality using views?
Comment #5
zmove CreditAttribution: zmove commentedOn a module developper side, it make sense that a field collection with a taxonomy would not associate the node to the taxonomy because it's an entity.
But on a drupal user side, that use field collection to merge several fields and extend core fields feature. It would be nice to have an out of the box way associate the node with the taxonomy terms added in a field collection, because this is the behavior that +95% people will want when adding a taxonomy term to a field collection.
I think the best way to do it is not to use views, but to use rules. To add or remove terms to the node on creation or update event. It would be less ressource intensive than creating the relation with views and calculate it for each node listing that will need it.
Maybe an exemple rule could be created for people that want to do it.
Comment #6
jsheffers CreditAttribution: jsheffers commentedHas there been any update on this? Can it be done with views or panels? Any ideas how to achieve what @zmove reccomended in the above comment to attach those terms to a node using rules?
Comment #7
thatjustin CreditAttribution: thatjustin commentedAnyone know how to do what zmove described in #5?
Comment #8
oda CreditAttribution: oda commentedthatjustin, just install rules module and create a new rule ;)
I'm attaching an example. To use it just add a field collection (in my rule example its named is "field_album_fields") to your content type, then add the field_tag to this field collection.
Hope this helps!
Comment #9
oda CreditAttribution: oda commenteddamn
Comment #10
thoughtcat CreditAttribution: thoughtcat commentedHi oda, thanks for pasting that code. Where do I use it exactly? I've tried creating a new rule but I'm getting lost trying to translate your code into the steps required to create a rule using the rules UI. I can't see anywhere I can just paste your code into my site somewhere and modify it.
My field collection is called "field_personnel". Do I have to add a new field to the collection called "field_tags" to get this to work?
Many thanks.
Comment #11
thoughtcat CreditAttribution: thoughtcat commentedIgnore my last post, I've found out how to import a rule. I've pasted oda's code and changed the field names to reflect my own fields, but am getting "Integrity check for the imported configuration failed. Error message: The data type of the configured argument does not match the parameter's list requirement.."
These are what I changed:
Any ideas?
Thanks :)
Comment #12
alpp CreditAttribution: alpp commentedi also had the same error while trying to import the rule above.
oda, can you please give us some hints on the loop and actions that you used in that rule?
Comment #13
errand CreditAttribution: errand commentedHello!
Any with this problem?
Comment #14
alpp CreditAttribution: alpp commenteddo you think this will be accomplished in drupal 8?
Comment #15
matt2000 CreditAttribution: matt2000 commentedThe actual issue is that the node/term relationship doesn't get written to the core taxonomy_index table when the term field is part of a field collection. Field Collection needs to handle this with code similar to what EntityReference module has.
Comment #16
andileco CreditAttribution: andileco commentedHey All,
I was able to use this module (https://drupal.org/project/taxonomy_entity_index) to help me overcome this issue--it worked with term references but not entity references. Maybe some of the code from this module could be incorporated into field collection--or at least it might spark some ideas.
Comment #17
daulet2030 CreditAttribution: daulet2030 commentedHow exactly did you solve this issue andile2012? I installed entity index module and indexed everything, i still cant see nodes that have the term in a field collection on its term page.
Could you describes steps needed?
Comment #18
andileco CreditAttribution: andileco commentedThanks, @daulet2030, for your question. Looking back, it didn't do exactly what I thought it did... I can show nodes tagged by terms from a term reference field included in the field collection, but it only works for nodes that contain the field collection. Let me explain:
Assume:
ContentType1 - contains a field collection called "Languages", with a term reference field called "Language" (which references a vocabulary called "Language") and a list (integer) field called Skill Level
ContentType2 - also contains field collection "Languages"
ContentType3 - contains a term reference field for the "Language" vocabulary
--> You can use Taxonomy Entity Index to create a view that shows all nodes tagged using the Language term reference field within the Languages field collection (see code below) - so you will see nodes of ContentType1 and ContentType2, but none of ContentType3
...so it's not a great solution for most sites...it doesn't do what I was thinking it did.
But this may still be useful. I didn't see how to form the correct relationships to do this without the module. But I could have very easily missed something.
OK, code below:
Comment #19
znerol CreditAttribution: znerol commentedI've posted a simple module capable of adding terms on entities nested within nodes to the
taxonomy_index
.Comment #20
Marko B CreditAttribution: Marko B commentedDid somebody try to solve issues here with this module in the end, that uses SHS ?
https://www.drupal.org/node/1354446
Comment #21
haunted CreditAttribution: haunted commented@zenerol
Your module works perfectly for my field collection's taxonomy terms, thank you!
Comment #22
aruiz360 CreditAttribution: aruiz360 commentedHi everyone.
I had the same problem but solved it another way.
Just add a relationship: the field with the term reference.
Then filter the content not by Has taxonomy term but by the term itself.
Thanks to everybody for the help!
Comment #23
kaztur CreditAttribution: kaztur commented#19 works for me. Great thank You, @znerol!
Comment #24
ladybug_3777 CreditAttribution: ladybug_3777 commentedUpdate: The module Taxonomy Deep Index: https://www.drupal.org/project/taxonomy_deep_index has an issue with writing duplicate entries to the taxonomy_index table that I just discovered. See this post: https://www.drupal.org/node/2399655
For me, until that issue is resolved, it isn't a viable solution yet.
UPDATE: There has been a fix released for the module issue above.
Comment #25
rivedav CreditAttribution: rivedav commentedI have the same issue with Drupal 8. Does anybody have an Idea to solve this issue: Fieldcollection items that have a taxonomy field assigned and a term given are not shown on the corresponding taxonomy page nor any views created
Comment #26
ladybug_3777 CreditAttribution: ladybug_3777 commentedRivedav,
It doesn't look like Taxonomy Deep Index has a version 8 module :-( That's what I ended up having to use to get this fixed in version 7.
Not sure how hard it would be to upgrade the taxonomy deep index module to work with 8.... but maybe ask about it in that issue queue?
Comment #27
haunted CreditAttribution: haunted as a volunteer commented@rivedav You can create view that overrides the taxonomy term page.
You have to make a view of contents, set the page url as Path: /taxonomy/[vocabulary name]/%, add the relationship between the content and the field collection field, and then a relationship between the field collection field and the field collection item (the term reference field).
Then you have to add a contextual filter for the field collection item (the term reference field) and tell it to grab the taxonomy term id from the url.
The problem is that this will override all the vocabularies unless you use also a module like https://www.drupal.org/project/taxonomy_display , but this has not been ported to drupal 8 yet.
Comment #28
ABaier CreditAttribution: ABaier commentedI tried the solution proposed in #27 and it worked as long as I defined it only for one vocabulary. In my case (drupal 8.15) I have three field collections in my node type with each an other term reference field, sorted in individual vocabularies. So I basically want to override the general handling of the taxonomy pages to target all of them. But if I duplicate the first view, change the url pattern to the next vocabulary name and reset the contextual filter and relationships to the specific fields, none of the views would show contents anymore. Would this also be possible in a single view? I don't know if it is possible to set multiple contextual filters and define them with an OR statement …
Another thing I would like to achive is, that the original url pattern for the taxonomy terms (/taxonomy/term/id) is kept, so that the links of the terms target the right pages, so that I don't have to set them individually.
Any help appreciated! Thanks in advance.
Comment #29
jmuzz CreditAttribution: jmuzz commentedJust to clarify, this issue is about getting the nodes that contain the field collection with the term to appear on the taxonomy page, right?
That seems to be what the comments suggest, and if that's the case I agree with #15 it should be the behaviour. #2509254: Field collection fields should extend entity reference fields
The issue summary talks about getting the field collection items themselves on the taxonomy pages. I think that was the understanding behind #3 and that is not something we can support.
Comment #30
ABaier CreditAttribution: ABaier commentedYou are right @jmuzz. The nodes containing the field collection with the term field should appear on the taxonomy pages. Like they would show up, if the term reference would be placed into the node directly.
Comment #31
jmuzz CreditAttribution: jmuzz commentedDevelopment is moving to 8.x-3.x.
Comment #32
alpp CreditAttribution: alpp commentedWill this issue be solved in 8.x-3.x. version?
Comment #33
ram4nd CreditAttribution: ram4nd as a volunteer commented