Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fields on field collections are matching the wrong template suggestion. #6

Open
jenlampton opened this issue Mar 8, 2022 · 3 comments
Labels
type - bug report Something isn't working

Comments

@jenlampton
Copy link
Member

jenlampton commented Mar 8, 2022

I have a field collection field named field_steps on a node. I want the steps to be rendered as an ordered list, so I have overridden field--field-steps.tpl.php to change the markup. Now, every field on my field collection item is also being rendered using this template.

It appears that there are new theme hook suggestions being added for the inner fields in the pattern field--PARENT-FIELD-NAME--FIELD NAME, but this unfortunately will also match field--PARENT-FIELD-NAME if that template exists :(

This new suggestion should be changed to ``field--SOMETHING_ELSE--FIELD-NAMEwhere the something else is not going to accidentally match a different template. Maybe something likeparent-FIELD-NAME` or `child-of-FIELD-NAME` if we still want the name of the parent field included.

I looked through the field collection code, but couldn't see where the extra theme hook suggestions were being added. Do you know if this is something that's happening intentionally because of this module? Or do you think it's accidentally happening due to some problem somewhere else?

@oadaeh
Copy link
Collaborator

oadaeh commented Mar 14, 2022

There are no theme hook suggestions being added, nor are there any in the D7 module.

When I looked at what templates were being recommended with theme_debug, these are showing up for D7

  • field-collection-item--{$field_collection_id}.tpl.php
  • field-collection-item--{$field_collection_machine_name}--{$view_mode}.tpl.php
  • field-collection-item--{$field_collection_machine_name}.tpl.php
  • field-collection-item.tpl.php

But they don't show up for Backdrop. So, I'm guessing the module is utilizing whatever default functionality is happening in Drupal, but Backdrop is doing something somewhat different in that area, and therefore, I probably need to add something to the module to account for that.

I see that Multified is not adding anything and does not have any template suggestions. Does that one work for you as you expect?
I also see that Paragraphs is adding theme hook suggestions, and they show up. Maybe I should mimic that module's behavior.

@jenlampton
Copy link
Member Author

I also see that Paragraphs is adding theme hook suggestions, and they show up. Maybe I should mimic that module's behavior.

I think there's an issue in the paragraphs queue because those aren't working as expected either. I think entity_plus is also involved, which causes problems.

I'll have a closer look and see where these are coming from... thank you!

@herbdool herbdool added the type - bug report Something isn't working label Jul 25, 2023
@herbdool
Copy link

I'm trying to wrap my head around the original report so I created a field collection field and a couple of fields attached to it.

The field collection field is field_weight. And the children are field_mass and field_unit. Theme debug shows this:

<!-- FILE NAME SUGGESTIONS:
   * field-collection-item--1.tpl.php
   * field-collection-item--field-weight--full.tpl.php
   * field-collection-item--field-weight.tpl.php
   x field-collection-item.tpl.php
   * entity-plus.tpl.php
-->

It doesn't show any suggestions for child fields.

When I add field-collection-item--field-weight--full.tpl.php into a theme it gets picked up. And when I add field--field-mass.tpl.php it gets picked up, just for the one field. And theme debug shows:

<!-- BEGIN OUTPUT from 'themes/abc/templates/field--field-mass.tpl.php' -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type - bug report Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants