- Issue created by @pdureau
- πΊπΈUnited States dalemoore
Here are my steps to reproduce. Some in the first steps sub-bullets may not be needed but including?
- You will need some SDCs to use. I have a parent SDC called Social Links and a child one called Social Link. (@pdureau should already have these, they were included in the Slack conversation)
- Make sure you have Display Suite and Display Suite Extras installed. This is used to select a component layout within Manage Display. Under Display Suite (admin/structure/ds/settings), I have these settings:
- Enable field templates
- Enable field templates in Layout Builder
- Default Field Template: Expert
- Under Extra fields, nothing selected
- Under Other, "Use field names in templates" and "Exclude Display Suite Layouts in Layout Builder" are checked"
- Nothing checked in BC settings
- Create a paragraph type (in my case, it's called Social Link - this is the child component) and add whatever fields you want to it, including at least one Entity Reference field (I have a taxonomy term one called Network that references social network names, e.g., Facebook, Instagram, etc.).
- Create a block type (in my case, it's called Social Links - this is the parent component) and add whatever fields you want, including one Entity Reference Revisions/Paragraphs field that uses the previously-created paragraph type.
- Go ahead and add an instance of the block somewhere on your page in a region (I'm not using Layout Builder here, just the block UI).
- Under Manage Display for the block type, make sure it's set to "Referenced entity" under Format for the Entity Reference Revisions field. That's all you need here.
- Under Manage Display for the paragraph type, with Display Suite installed, under "Current layout" select the SDC you want to use from the dropdown list (for me, it is the child component Social Link) and save.
- Go to "Layout settings" still in the paragraph type, and map the props to the appropriate fields. The only options to start are "Data from a field" or "Referenced entities", there is no initial "Prop: entity" available like there is when using "Components per item" in the sibling issue. π Introduce a new source to get access to the current "i-th" referenced entity from a field entity reference in the context of component per item field formatter Active I choose "Data from a field" for each.
- Once all fields are mapped, save, then go back and refresh the page to view your block.
- I get a ContextException error message.
Sending a video of the steps in Slack.
- π«π·France just_like_good_vibes PARIS
Thanks for reporting.
After investigation, this error occurs when using the contrib module ds, when a layout from ui patterns is configured in a content entity display (here a paragraph), and in the layout settings, a source with the current entity is used.
it works in form configuration, but fails to properly render.
Indeed, for the moment, ui_patterns module is not providing itself a way to guess the current entity inside ds_entity_view layout options. - π«π·France pdureau Paris
Indeed, for the moment, ui_patterns module is not providing itself a way to guess the current entity inside ds_entity_view layout options
UI Patterns target both Core & contrib modules, but we target by default only Core plugin types: Blocks, Layouts, Formatters...
Display Suite is using both:
- core plugin types (Layout for example) and it is supposed to work directly with
ui_patterns_layouts
sub-module if the usage of Dsipaly Suite is a "normal" (no weird additions or alteration) - a custom plugin type ("DS Field"), for this one,
ui_patterns_ds
is needed
So, are we 100% sure it is not working because of DS?
- If yes,
- we need to create an issue to https://www.drupal.org/project/issues/ui_patterns_ds β to deal with that.
- in our codebase, we need to make sure a fatal error is not triggered in those situations (not only with DS, more generic)
- If not, we need to tweak something in our codebase.
So, anyway, it seems there is something to do for the RC2.
- core plugin types (Layout for example) and it is supposed to work directly with
- πΊπΈUnited States dalemoore
a custom plugin type ("DS Field"), for this one, ui_patterns_ds is needed
To my knowledge I'm not using a DS Field, but I could be wrong. Would I have to select one of these options in the layout dropdown under Manage Display to do something like that?
Or, this option would need to be enabled maybe:
Or something on this screen?
I'm not sure what exactly a DS Field is, I haven't used the things found in the last two screenshots before. In the past I would only use what's in the first screenshot, which allows me to override the template, add attributes/classes to fields, etc.
The only thing I'm using DS in this case is to select an SDC on the Manage Display screen layout dropdown without having to rely on Layout Builder (because I don't wish to manipulate layout visually, just do mapping to the SDC) or Field Layout (this module is to be deprecated and will be removed from Core, see this issue π Inform users that Field Layout is deprecated Active , this issue π [META] Enable layout builder for form displays, and deprecate field_layout Postponed , and this issue π Move Field Layout data model and API directly into \Drupal\Core\Entity\EntityDisplayBase Needs work ). I haven't tried using Field Layout before, but I just did on a separate bare Drupal install. It doesn't seem to offer the ability to control field layout under "Manage display" any more, only under "Manage form display", so using Field Layout instead of Display Suite won't work.
- Merge request !326Issue #3500244 by dalemoore, pdureau, just_like_good_vibes: [2.0.0-rc2] ContextException with entity:paragraph β (Merged) created by just_like_good_vibes
- π«π·France just_like_good_vibes PARIS
For the moment, let's catch context exceptions and send a message to drupal logs...
- π«π·France pdureau Paris
The change is great, thanks.
Before merging and closing the issue, we need to create the related issue in https://www.drupal.org/project/issues/ui_patterns_ds β
Do you want to do it?
- π«π·France pdureau Paris
issue created π Compatibility with UI patterns 2 Active
Duael is currently testing with Field Layout
- π«π·France duaelfr Montpellier, France
I have a similar issue with the following steps to reproduce (also reproduced by @g4mbini on a clean install):
- Enable Field Layout
- Have a SDC with a string prop
- In the manage display form of one of your node types, in the layout settings section, select your SDC
- In the props settings, for your prop select "Referenced entities" the any referenced entity then any option in the Source select
- Save your settings to see the error
I applied the patch from the MR and I'm still able to reproduce.
Here is my stack trace:Drupal\Component\Plugin\Exception\ContextException: The 'entity:node' context is required and not present. in Drupal\Core\Plugin\Context\Context->getContextValue() (line 73 of core/lib/Drupal/Core/Plugin/Context/Context.php). Drupal\ui_patterns\Plugin\UiPatterns\DerivableContext\EntityReferencedDerivableContext->getDerivedContexts() (Line: 124) Drupal\ui_patterns\Plugin\UiPatterns\Source\DerivableContextSourceBase->getSourcePlugins() (Line: 470) Drupal\ui_patterns\Plugin\UiPatterns\Source\DerivableContextSourceBase->calculateDependencies() (Line: 264) Drupal\ui_patterns\Element\ComponentElementBuilder->calculateComponentDependenciesProps(Object, Array, Array) (Line: 238) Drupal\ui_patterns\Element\ComponentElementBuilder->calculateComponentDependencies('ccu_theme:card_highlight', Array, Array) (Line: 234) Drupal\ui_patterns_layouts\Plugin\Layout\ComponentLayout->calculateComponentDependencies('ccu_theme:card_highlight', Array) (Line: 170) Drupal\ui_patterns_layouts\Plugin\Layout\ComponentLayout->calculateDependencies() (Line: 71) Drupal\Core\Config\Entity\ConfigEntityBase->getPluginDependencies(Object) (Line: 89) Drupal\Core\Config\Entity\ConfigEntityBase->calculatePluginDependencies(Object) (Line: 149) Drupal\field_layout\Entity\FieldLayoutEntityViewDisplay->calculateDependencies() (Line: 328) Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object) (Line: 272) Drupal\Core\Entity\EntityDisplayBase->preSave(Object) (Line: 114) Drupal\field_layout\Entity\FieldLayoutEntityViewDisplay->preSave(Object) (Line: 528) Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 483) Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 239) Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object) (Line: 354) Drupal\Core\Entity\EntityBase->save() (Line: 617) Drupal\Core\Config\Entity\ConfigEntityBase->save() (Line: 293) Drupal\Core\Entity\EntityForm->save(Array, Object) call_user_func_array(Array, Array) (Line: 105) Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 43) Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 589) Drupal\Core\Form\FormBuilder->processForm('entity_view_display_edit_form', Array, Object) (Line: 321) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73) Drupal\Core\Controller\FormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28) Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36) Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 709) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
- π«π·France just_like_good_vibes PARIS
expect an answer and new version very soon, within minutes :)
- πΊπΈUnited States dalemoore
I tried the updated code as a patch (alongside the other issue's code which I still have patched in), switching my 'Social Links' component to use 'Rendered entity' instead of 'Components per item', then in the paragraph type mapping the fields to the props. Instead of the ContextException I now get this:
The website encountered an unexpected error. Try again later. Error: Call to a member function get() on null in Drupal\ui_patterns\Plugin\UiPatterns\Source\FieldPropertySource->getPropValue() (line 33 of modules/contrib/ui_patterns/src/Plugin/UiPatterns/Source/FieldPropertySource.php). Drupal\ui_patterns\SourcePluginBase->getValue() (Line: 98) Drupal\ui_patterns\Plugin\UiPatterns\Source\DerivableContextSourceBase->getPropValue() (Line: 199) Drupal\ui_patterns\SourcePluginBase->getValue() (Line: 91) Drupal\ui_patterns\Element\ComponentElementBuilder->buildProp() (Line: 71) Drupal\ui_patterns\Element\ComponentElementBuilder->buildProps() (Line: 52) Drupal\ui_patterns\Element\ComponentElementBuilder->build() call_user_func_array() (Line: 113) Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 870) Drupal\Core\Render\Renderer->doCallback() (Line: 432) Drupal\Core\Render\Renderer->doRender() (Line: 248) Drupal\Core\Render\Renderer->render() (Line: 484) Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 44) __TwigTemplate_9fd84133cf2adb9e74cfdc062566cfd5->doDisplay() (Line: 387) Twig\Template->yield() (Line: 343) Twig\Template->display() (Line: 358) Twig\Template->render() (Line: 35) Twig\TemplateWrapper->render() (Line: 33) twig_render_template() (Line: 348) Drupal\Core\Theme\ThemeManager->render() (Line: 491) Drupal\Core\Render\Renderer->doRender() (Line: 248) Drupal\Core\Render\Renderer->render() (Line: 484) Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 244) __TwigTemplate_bc21571d82fec26cc5a2a823aa2651a1->{closure}() (Line: 2058) Twig\Extension\CoreExtension::captureOutput() (Line: 213) __TwigTemplate_bc21571d82fec26cc5a2a823aa2651a1->macro_content() (Line: 191) __TwigTemplate_bc21571d82fec26cc5a2a823aa2651a1->{closure}() (Line: 2058) Twig\Extension\CoreExtension::captureOutput() (Line: 119) __TwigTemplate_bc21571d82fec26cc5a2a823aa2651a1->macro_field() (Line: 87) __TwigTemplate_bc21571d82fec26cc5a2a823aa2651a1->doDisplay() (Line: 387) Twig\Template->yield() (Line: 343) Twig\Template->display() (Line: 358) Twig\Template->render() (Line: 35) Twig\TemplateWrapper->render() (Line: 33) twig_render_template() (Line: 348) Drupal\Core\Theme\ThemeManager->render() (Line: 491) Drupal\Core\Render\Renderer->doRender() (Line: 504) Drupal\Core\Render\Renderer->doRender() (Line: 248) Drupal\Core\Render\Renderer->render() (Line: 484) Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 86) __TwigTemplate_3150cca8781d01d314c0ea2fc77e4d3e->doDisplay() (Line: 387) Twig\Template->yield() (Line: 165) __TwigTemplate_f755c51af21e4ba003b7403eadf7f91a___59522040->doDisplay() (Line: 387) Twig\Template->yield() (Line: 44) __TwigTemplate_f755c51af21e4ba003b7403eadf7f91a->doDisplay() (Line: 387) Twig\Template->yield() (Line: 343) Twig\Template->display() (Line: 358) Twig\Template->render() (Line: 35) Twig\TemplateWrapper->render() (Line: 234) Drupal\Core\Template\TwigEnvironment->renderInline() (Line: 54) Drupal\Core\Render\Element\InlineTemplate::preRenderInlineTemplate() call_user_func_array() (Line: 113) Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 870) Drupal\Core\Render\Renderer->doCallback() (Line: 432) Drupal\Core\Render\Renderer->doRender() (Line: 504) Drupal\Core\Render\Renderer->doRender() (Line: 248) Drupal\Core\Render\Renderer->render() (Line: 484) Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 44) __TwigTemplate_9fd84133cf2adb9e74cfdc062566cfd5->doDisplay() (Line: 387) Twig\Template->yield() (Line: 343) Twig\Template->display() (Line: 358) Twig\Template->render() (Line: 35) Twig\TemplateWrapper->render() (Line: 33) twig_render_template() (Line: 348) Drupal\Core\Theme\ThemeManager->render() (Line: 491) Drupal\Core\Render\Renderer->doRender() (Line: 248) Drupal\Core\Render\Renderer->render() (Line: 484) Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 152) __TwigTemplate_bc05fafc2639a509ad8ac530045c2abd->block_content() (Line: 431) Twig\Template->yieldBlock() (Line: 89) __TwigTemplate_bc05fafc2639a509ad8ac530045c2abd->block_wrapper() (Line: 431) Twig\Template->yieldBlock() (Line: 53) __TwigTemplate_bc05fafc2639a509ad8ac530045c2abd->doDisplay() (Line: 387) Twig\Template->yield() (Line: 343) Twig\Template->display() (Line: 358) Twig\Template->render() (Line: 35) Twig\TemplateWrapper->render() (Line: 33) twig_render_template() (Line: 348) Drupal\Core\Theme\ThemeManager->render() (Line: 491) Drupal\Core\Render\Renderer->doRender() (Line: 504) Drupal\Core\Render\Renderer->doRender() (Line: 248) Drupal\Core\Render\Renderer->render() (Line: 484) Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 178) __TwigTemplate_00e51af2befcc5fa6f56f8cd1ffdd83c->doDisplay() (Line: 387) Twig\Template->yield() (Line: 343) Twig\Template->display() (Line: 358) Twig\Template->render() (Line: 35) Twig\TemplateWrapper->render() (Line: 33) twig_render_template() (Line: 348) Drupal\Core\Theme\ThemeManager->render() (Line: 491) Drupal\Core\Render\Renderer->doRender() (Line: 248) Drupal\Core\Render\Renderer->render() (Line: 484) Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 128) __TwigTemplate_31cd56f2962c65fbb44761101472ce3c->doDisplay() (Line: 387) Twig\Template->yield() (Line: 343) Twig\Template->display() (Line: 358) Twig\Template->render() (Line: 35) Twig\TemplateWrapper->render() (Line: 33) twig_render_template() (Line: 348) Drupal\Core\Theme\ThemeManager->render() (Line: 491) Drupal\Core\Render\Renderer->doRender() (Line: 248) Drupal\Core\Render\Renderer->render() (Line: 158) Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638) Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 153) Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90) Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() call_user_func() (Line: 111) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186) Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76) Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53) Drupal\Core\StackMiddleware\Session->handle() (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28) Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32) Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116) Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90) Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36) Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51) Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 176) Drupal\Core\EventSubscriber\DefaultExceptionHtmlSubscriber->makeSubrequest() (Line: 119) Drupal\Core\EventSubscriber\CustomPageExceptionHtmlSubscriber->makeSubrequestToCustomPath() (Line: 81) Drupal\Core\EventSubscriber\CustomPageExceptionHtmlSubscriber->on404() (Line: 109) Drupal\Core\EventSubscriber\HttpExceptionSubscriberBase->onException() call_user_func() (Line: 111) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 239) Symfony\Component\HttpKernel\HttpKernel->handleThrowable() (Line: 91) Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53) Drupal\Core\StackMiddleware\Session->handle() (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28) Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32) Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116) Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90) Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36) Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51) Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741) Drupal\Core\DrupalKernel->handle() (Line: 19)
- π«π·France pdureau Paris
- Fresh Drupal isntall
- Enable Field Layout, UI Patterns 2 and UI Suite DSFR theme
- Use
- In /admin/structure/types/manage/article/display select the UI Suite DSFR alert component as a layout
- For the "Close button text" prop (string), select "Referenced entities" then any referenced entity then any field
- Save your settings and check the full page of an article
It works well. The data is retrivied and send to the prop.
- π«π·France pdureau Paris
Fresh Drupal isntall
Enable Field Layout, UI Patterns 2 and UI Suite DSFR theme
Use
In /admin/structure/types/manage/article/display select the UI Suite DSFR alert component as a layout
For the "Close button text" prop (string), select "Referenced entities" then any referenced entity then any field
Save your settings and check the full page of an article - π«π·France pdureau Paris
Or maybe it is a DS specific issue? I have tested only with Field Layout
- π«π·France just_like_good_vibes PARIS
For Display suite users, one can look at the solution shown in that issue π Compatibility with UI patterns 2 Active . It will be implemented in the future in
ui_patterns_ds
module. -
just_like_good_vibes β
committed f1d2c273 on 2.0.x
Issue #3500244 by just_like_good_vibes, pdureau, dalemoore, duaelfr,...
-
just_like_good_vibes β
committed f1d2c273 on 2.0.x
- π©πͺGermany Christian.wiedemann
just_like_good_vibes β credited christian.wiedemann β .
- π«π·France duaelfr Montpellier, France
I woke up this morning to see this fixed.
Congratulations and many thanks for this!! Automatically closed - issue fixed for 2 weeks with no activity.