Problem/Motivation
View modes are part of the field instance export. That means that it is not possible to export separate view modes, without affecting the original feature. Separating the view modes per field instance would enable the possibility of providing different view modes on different sites, without affecting the 'base' feature.
Example 1
Let's say I have a platform with multiple sites. For one of the sites I wish to have an extra view mode. Ideally, this could be exported into it's own Feature, leaving all other sites unaffected.
Example 2
Again, a platform with multiple sites. On one site I wish to adjust the view mode for the teaser. If the view modes where exported seperately, I could disable the 'Base'-teaser-view-mode and create a new one, just for that one particular site.
Proposed resolution
It would be nice if field instances could be exported per view mode. So instead of this:
[entity]-[bundle]-[field]
We would end up with this:
[entity]-[bundle]-[field]-[view-mode]
For existing features [entity]-[bundle]-[field] should keep working, but when exporting it should include the [view-mode].
(Note this is a very similar approach to #1064472: separate fields from field instances)
Remaining tasks
Right now I would like to know if this is feasible. I did some research, but I have not been able to discover if this was somehow already possible, perhaps I have missed something.
Related Issues
#1064472: separate fields from field instances
#1211008: Split field_bundle_settings out per bundle
Comment | File | Size | Author |
---|---|---|---|
#10 | features-separate-field-instances-from-view-modes-2029577-10.patch | 15.92 KB | frodri |
| |||
#9 | features-separate-field-instances-from-view-modes-2029577-09.patch | 15.42 KB | frodri |
| |||
#6 | interdiff-2029577-03-06.txt | 4.93 KB | ndf |
#6 | features-separate-field-instances-from-view-modes-2029577-06.patch | 15.61 KB | ndf |
Comments
Comment #1
hefox CreditAttribution: hefox commentedHow about using features overrides?
Comment #2
dagomar CreditAttribution: dagomar commentedThanks for your reply Hefox!
Yes, features overrides is indeed what I am using right now to solve this issue. However, that adds a dependency to the platform that I would rather omit, it feels like a hack basically. What I propose would be a cleaner solution, it would give the opportunity to pack certain features in a much more logical way. A content type may have an add-on feature that consists of a custom view, and a custom view mode used in that view. In my proposal that would cleanly export, with features override that wouldn't. An untested assumption I make here is that I cannot have 2 overrides for the same content type, so I assume it is not possible to have a second add-on feature for the content introducing yet another view mode. I will test to make sure that my assumption is right.
I understand that the issue is perhaps an edge case, but I think it would be of great benefit for us developers. It would make it so much easier to extend without breaking anything.
Oh I forgot, I realized this *may* be more an issue for core first, if so, perhaps this issue should be moved there.
Comment #3
ndf CreditAttribution: ndf at Blue Carpet commentedThis patch separates 'field instances display' settings from 'field instances'.
Effectively this lets you export each field-instance for each view-mode separately. This solves Example 1 and 2.
before
field_instance: node-news-body
after
field_instance: node-news-body
field_instance_display: node-news-body-full
field_instance_display: node-news-body-teaser
Note that this separation is superficial, Drupal Core does not have a distinction between field-instances-displays and field-instances. Field-instances-displays are saved within field-instances.
If you apply this patch you have to recreate all features that have field-instances.
Comment #5
ndf CreditAttribution: ndf at Blue Carpet commentedNeeds tests. Test for field_instance (that is altered) is failing now.
Comment #6
ndf CreditAttribution: ndf at Blue Carpet commentedAdded tests.
Comment #7
ndf CreditAttribution: ndf at Blue Carpet commentedSnippet that adds field_instance_displays when adding a display-suite layout to a feature.
Comment #8
ndf CreditAttribution: ndf at Blue Carpet commentedThink I will create a new module that combines patch + above snippet.
It should replace
includes/features.field.inc
with the one in the patch.Quite sure its documented in some ticket how to do that, cannot find it now.
Comment #9
frodri CreditAttribution: frodri commentedPatch on comment #6 breaks on Features version 2.11+. An updated patch is attached below.
Comment #10
frodri CreditAttribution: frodri commentedRerolling patch for Features version 2.14.