when I add a referenced custom block after translating it, the layout page does not pick up the added blocks

Created on 29 May 2024, about 1 year ago
Updated 3 June 2024, about 1 year ago

Problem/Motivation

I have a custom block called “a column” with a field that references other custom blocks and allows me to create, duplicate or delete multiple custom blocks. The field is enabled to be translated, as are the referenced blocks.

When translating the “one column” block and saving changes to the translations layout, when I add or duplicate a custom block and save it in the original language, when reviewing the translation, the new block is not added to the translation in either the view or layout.

Steps to reproduce

  1. Create a translatable custom block and add a translatable field that references one or more custom blocks and allows unlimited values.
  2. enable in the form display in the added field the option “Inline entity form - Complex” and in control options enable the option to add new entity custom blocks and duplicate.
  3. Create a translatable custom block and add a translatable field that references one or more custom blocks and allows unlimited values.
  4. Create a layout page (ES) and add a section with the block “one column”, then from the multiple field create a custom block and save changes.
  5. Translate layout page to EN and translate "one column" block from layout and save changes.
  6. Return to the source language layout and configure the “one column” block to create another custom block, then save changes.

Then when reviewing the translation you would not see the custom blocks added from the original design after translating it.

Thanks in advance for your help!

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇴Colombia wilsotoa Cucuta, Norte de Santander

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇴Colombia wilsotoa Cucuta, Norte de Santander

    Hi, I have been testing with two patches and it seems that the error is because when I update the block and save the translation it creates a new revision in the instantiated block but does not update the revision in the source language, but even applying these patches when I go to the source layout it reports changes without saving then I modify the block and save the changes but it still has the revision id out of date.
    https://www.drupal.org/files/issues/2021-07-06/layout_builder_st-3222423...
    https://www.drupal.org/files/issues/2023-04-25/layout_builder_st-3108061...

  • @wilsotoa
    You don't have to enable translations for the custom block type (In your case "a column").
    You only have to enable it in the custom blocks type you want to add in the entity reference field. With that once you add an entity reference block in your custom block, it will appear in the rest of the translations. To get the translation of that block you have to go to /admin/content/block, and there in your block, generate the translation in the language you want to appear already translated in your custom block.

  • 🇨🇴Colombia wilsotoa Cucuta, Norte de Santander

    Hello @fruizalejos, thank you for your response.
    In my case this does not solve the problem, since the content editor user does not have access to /admin/content/block and they handle the block translations from the translated layout.

  • First commit to issue fork.
  • Created an MR that addressed this issue, also updated IS, steps to reproduce and title.

  • heddn Nicaragua

    This leads to an infinite loop on any content created and translated with this patch installed. Not on the first addition of the translation, but rather on subsequent saves. This infinite loop happens on any translation, including the original. Something in the setup of the content during the cloning is causing this. Because if I comment out the presave and shutdown function, then try to resave, it still infinite loops.

  • heddn Nicaragua

    That last seems to work without any nasty side effects

  • heddn Nicaragua

    That last fix solves the issue with null blocks. What it doesn't fix is that the handler is a presave. So on initial block placement, there aren't block IDs to clone into the additional languages. This needs to move into a post save hook handler so the blocks can IDs that get cloned into additional languages.

  • heddn Nicaragua

    Reworked into a post save (hook_update) handler. That seemed to fix things.

  • 🇨🇦Canada joseph.olstad

    This seems much more complicated than the other available solution

  • 🇨🇦Canada joseph.olstad

    Seems that there's several issues here, not sure which one is a duplicate.

    🐛 Nontranslatable custom block fields are not synchronized between translations Needs review

  • Status changed to Needs review about 1 month ago
  • 🇧🇷Brazil aluzzardi Pelotas, RS

    Applying the diff from here I have this issue:

     Error: Call to protected method Drupal\layout_builder\SectionComponent::getConfiguration() from scope Drupal\layout_builder_st\LayoutBuilderEntityHandler in Drupal\layout_builder_st\LayoutBuilderEntityHandler->update() (line 69 of modules/contrib/layout_builder_st/src/LayoutBuilderEntityHandler.php).
    
Production build 0.71.5 2024