Hi all ,

When I override a basic template, fieldgroup not work. Example, I add a tag 'div.toto' has my full display page it works. however, if I override my template full display page like this "node--page--full.html " keeping the same code. tags fieldgroup are not rendered.

it's same if i override with DS.

It's bug ?

Sorry for my english.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vanilla-bear created an issue. See original summary.

vanilla-bear’s picture

FileSize
225.27 KB
480.71 KB

After research i find my problem is situated here :
File : field_group.module
Function : field_group_theme_registry_alter

var $theme_registry contains my template override 'node__etude_de_cas__teaser' and 'node__integrateur'
but
var $entity_info contains only basic theming function.

To be honest i'm not sure understand everything but it's here that 'field_group_build_entity_groups' are not injected.

i hope help someone.

Olafski’s picture

There is the same or a similar similar behaviour using Field Group with a Display Suite layout. According to information of the following threads, the problem should be solved if you apply three patches regarding Drupal Core, Display Suite and Field Group:

Core: Field UI table is broken for nested elements
Display Suite: Field group compatibility
Field Group: Fields are not grouped when render element key is not elements

I updated to the relevant dev versions of Core, DS and FG, but when I create a field group, e.g. "HTML element" in a Display Suite layout, e.g. "One column", the field group still doesn't shows up on the node. (In contrast, it shows up if I deacitivate the Display Suite layout.)

So, possibly a new incompatibility between Display Suite and Field Group? (I'm posting here in the Field Group queue, because I found the active issue of vanilla-bear.)

aspilicious’s picture

This issue could be related. #2594123: fix for ds registry alter, variants of templates did not get picked up
Let me install and see if I can figure out the issue, the summary is a bit confusing.

aspilicious’s picture

Well apparently there are still issues with DS and field group, but this issue is something different

aspilicious’s picture

Can you try the following code, it's super ugly but at least it should work, but it can cause issues if there is a template that start with "node".

/**
 * Implements hook_theme_registry_alter().
 */
function field_group_theme_registry_alter(&$theme_registry) {

  // Inject field_group_build_entity_groups in all entity theming functions.
  $entity_info = Drupal::entityManager()->getDefinitions();
  $entity_types = array();
  foreach ($entity_info as $entity_type_id => $entity_type) {
    if ($route_name = $entity_type->get('field_ui_base_route')) {
      $entity_types[] = $entity_type_id;
    }
  }

  foreach ($entity_types as $entity_type) {
    foreach ($theme_registry as $theme_registry_item_key => $theme_registry_item) {
      if (substr($theme_registry_item_key, 0, strlen($entity_type)) == $entity_type) {
        $theme_registry[$entity_type]['preprocess functions'][] = 'field_group_build_entity_groups';
        // DS support, make sure it comes after field_group.
        if ($key = array_search('ds_preprocess_ds_layout', $theme_registry[$entity_type]['preprocess functions'])) {
          unset($theme_registry[$entity_type]['preprocess functions'][$key]);
          $theme_registry[$entity_type]['preprocess functions'][] = 'ds_preprocess_ds_layout';
        }
      }
    }
  }
}
Olafski’s picture

@aspilicious: At which place should one try the proposed code?

Stalski’s picture

Hi,

I am working on this issue and I have this problem without DS enabled. So it seems like a field_group problem.
As @aspilicious mentions, It could clash with DS since both modules want to hook in the same process and preferably as last one :) .

I'll update as soon as I localised the problem.

aspilicious’s picture

Stalski the problem is the same problem as my linked issue. In D7 you could assign a function to a generic entity template, that also worked for suggestions. In D8 the function needs to be added to each suggestion. Which is not easy, my code is a workaround that potentially can fail. Probably needs a core fix for a beter solution.

Stalski’s picture

Hi

Yes, I kind of figured that :)
Ofcourse the first approach I tried, was the workaround you posted. That is not working for me atm, I'll keep you posted ;)

aspilicious’s picture

Going to fix this

aspilicious’s picture

Status: Active » Needs review
FileSize
1.05 KB

Same fix as DS and Layout plugin.

aspilicious’s picture

DS support isn't needed as DS added fieldgroup support.
These lines were part of the D7 code I suppose and are incorrect/useless now.

swentel’s picture

Status: Needs review » Fixed

commited and pushed, thanks.

  • swentel committed 54354bf on 8.x-1.x authored by aspilicious
    Issue #2627194 by aspilicious: Fieldgroup not render override template
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Status: Closed (fixed) » Needs work

The last submitted patch, 12: 2627194-template-suggestion-fix.patch, failed testing.

swentel’s picture

Status: Needs work » Closed (fixed)