Needs work
Project:
Entity Embed
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
21 Apr 2014 at 16:50 UTC
Updated:
31 May 2019 at 10:55 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dave reidDave Reid:
slashrsm:
Comment #2
cs_shadow commentedClosing because of the fact that now we support display plugin options (which also provides values).
Comment #3
dave reidHrm, no we'll still want this. It would make a lot of sense to provide this oerut of the box. I'm ok with it being postponed for now.
Comment #4
cs_shadow commentedOk, in that case I do not understand how this would fit in the current form UI?
Comment #5
berdirTeaser is node specific, so that won't really help.
There is a now an event that is triggered when new entity types are discovered, see EntityTestDefinitionSubscriber.
So a combination of creating view modes for existing entity types on install + that for creating it for new ones should be possible?
Comment #6
berdirI don't see anything that this would be postponed on.
The embed view mode would simply be another option in the existing view mode selection. There is no need for changes there, other than considering to make this the default option. By default it would use the default display configuration, so same as full, but it's easy to configure it then from there.
Comment #7
slashrsm commentedComment #8
slashrsm commentedComment #9
slashrsm commentedUpdated issue summary to reflect #6.
Comment #10
slashrsm commentedComment #11
dave reidChanging the title changed the scope of this issue. This has always been about providing a default view mode that can be implemented/configured.
Comment #12
slashrsm commentedI don't understand why this should be postponed.
Based on #6 I understood that direction changed. Or do we have any better solution?
Comment #13
dave reidNo, I don't see any change in direction. We'd still need to provide the view mode for everything, which is what this issue is about.
Comment #14
slashrsm commentedOK. Then we need to bring everyone on the same page at least. Let's update issue summary to reflect what we actually need to do here. Are we expecting people to created view mode manually? What do we do if they don't? Are we creating view mode automatically for all entity types? If yes, how are we doing that?
Comment #15
wim leersI see the appeal of this: usability through consistency. If you're embedding an entity, it'd always be embedded using the view mode. Choosing a view mode would become the advanced use case.
On the other hand, I also see an important downside: we'd have to auto-generate an view mode for every entity type.
I just brought this up on a call with @seanB, @marcoscano, @phenaproxima, @ckrina, @webchick, @alex.pott and I. They were not very fond of my proposal to omit the ability to select a view mode (at least in Drupal core, as part of #2801307: [META] Support WYSIWYG embedding of media entities) and let that become the advanced-only case (which would be served by the
entity_embedmodule). They feel like it's actually quite common to allow the content author to select a view mode.Still, they did seem to like the idea of Drupal shipping with an
embedview mode out-of-the-box.Comment #16
wim leersThe key thing here is that this would allow sensible embedding of entities out-of-the-box once entity types start to provide default configuration for this (or even go further and provide Twig templates).
Comment #17
wim leersThis is probably more of a feature request though?
Comment #18
wim leersLooks like this could take inspiration from #2988433: Automatically create and configure Media Library view and form displays.
Comment #19
oknateHere's a patch that creates the embed entity_view_mode and entity_view_display for each selected bundle when creating an embed button.
It seems to me that creating a bunch of embed view modes for entities that might not ever be embedded doesn't make sense. It makes more sense to create them as needed, i.e., when creating an embed button that uses them.
If you put the code in an install hook and add it for every entity at the point of entity embed module install, it would miss entities added after you install entity embed. In other words, you would need a way to "discover" entities and create the embed view mode.
The solution:
1) When creating a new embed button, if an "Embed" view mode display plugin doesn't exist, display it as an option anyway.
2) When saving the form, if they haven't unselected "Embed" view mode, run code that creates the view mode for the target entity type, and entity_view_display configs for each bundle selected.
Comment #20
oknateHere's a screenshot of the "Embed" view mode selected by default when creating a new embed button. I also added a more verbose label (see screenshot), because I always found it a bit confusing what type of plugins they were. The label appends the deriver type.
Comment #21
oknateI believe this is the default behavior already.
Comment #22
oknateAdded some improvements, bug fixes and a test onto #19.
I haven't run the test yet, so I'm using the posting of patch to check it.
Comment #24
oknateadding field_ui dependency on the test.
Comment #25
oknateOK, this should work now. I got drupalci_testbot running locally and fixed the test.
Comment #26
oknateComment #27
oknateComment #28
oknateCoding standard fixes.
Comment #29
oknateComment #30
oknateOne coding standard fix and one other small change.
Comment #31
oknateAdding interdiff from #28 to #30.
Comment #32
oknateOne thing I added that I'm not sure should be there is the auto creation of entity_view_display configs for each bundle.
I know that I personally create these, so it makes sense to me. But it is possible to use the default entity_view_display configuration on a bundle with the embed view mode. If you wanted to delete the auto-generated entity_view_display (for example node.page.embed), resaving the embed button would regenerate it. So that would be annoying.
Comment #33
oknateHere's an update to #30 that removes the auto-generation of entity_view_display configs, based on the comments in #32.
Comment #34
oknatethe last patch includes changes for #2845085: Avoid conflating @EntityEmbedDisplay plugins and view modes, those should be removed.
Also, I don't know why I thought it was a good idea to assure the view mode exists at run time when editing the button. That seems very odd.
I think it should just be included in /config/install, and an update hook added.