Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've created a view pane that displays users, but only view modes for nodes are available for selection when I add this view pane to a page. I've found that the view mode options are hard-coded for nodes. I'm going to attempt a patch so that the view modes available will be those of the entity type the view is showing.
Comment | File | Size | Author |
---|---|---|---|
#15 | panopoly_magic_entity_view_modes-2144021-15-interdiff-do-not-test.patch | 4.57 KB | dsnopek |
#15 | panopoly_magic_entity_view_modes-2144021-15.patch | 6.24 KB | dsnopek |
Comments
Comment #1
whastings CreditAttribution: whastings commentedHere's the patch!
Comment #2
whastings CreditAttribution: whastings commentedI found that #1986056: Configuration modal shows wrong stuff for views content pane based on files also addresses this issue and has a patch, though it appears to be specific to file view modes.
Comment #3
Andrew Edwards CreditAttribution: Andrew Edwards commentedI marked #1986056: Configuration modal shows wrong stuff for views content pane based on files as a duplicate as the patch here has better code + is more generic.
It doesn't seem to apply against the latest dev though + needs some of the work from the other issue.
Working on it now.
Comment #4
Andrew Edwards CreditAttribution: Andrew Edwards commentedHmn. It's getting there. I've merged the two issues + have tidied things up a little.
At the moment all is working well I think up until the final bit: rendered entities are not being displayed once the modal is closed.
However, the preview is working now for node, file and user entities. I haven't tested other entity types.
I've clearly broken something though as node entities used to save fine with a view mode selected.
Comment #5
Andrew Edwards CreditAttribution: Andrew Edwards commentedComment #6
Andrew Edwards CreditAttribution: Andrew Edwards commentedOK. This one works for me.
The problem with entities not rendering after saving is fixed I think.
Comment #7
Andrew Edwards CreditAttribution: Andrew Edwards commentedImproved default view mode (sometimes no default was set).
If teaser is available it is set as the default, if not available then the first view mode returned is set as the default.
Comment #8
Andrew Edwards CreditAttribution: Andrew Edwards commentedUpdated patch for 7.x-1.6+2-dev
Also added code to check for old views that have something other than 'fields' or 'table' in settings.
If not 'fields' or 'table' then 'rendered_entity' is used. This is instead of 'nodes' for example.
I didn't just check for nodes as I have a legacy patch which added 'files'.
Comment #9
Andrew Edwards CreditAttribution: Andrew Edwards commentedComment #10
Andrew Edwards CreditAttribution: Andrew Edwards commentedComment #11
Andrew Edwards CreditAttribution: Andrew Edwards commentedHere's a new patch. Includes:
- fix to make sure preview defaults to teaser if no view mode is available (otherwise the first time a user views the form with a preview no view mode will be selected and the display will be a bit screwed)
- made this issue dependant on #2274023: Remove trailing whitespace from panopoly_magic.module as it was difficult to patch panopoly_magic.module with trailing whitespace
Comment #12
Andrew Edwards CreditAttribution: Andrew Edwards commentedAdjusted to include view_settings for preview
Still dependant on #2274023: Remove trailing whitespace from panopoly_magic.module
Comment #13
Andrew Edwards CreditAttribution: Andrew Edwards commentedAdjusted to make sure legacy way of storing entity type is changed within panopoly_magic_views_pre_view()
Comment #14
dsnopekHere is a version of this patch that doesn't depend on #2274023: Remove trailing whitespace from panopoly_magic.module. As explained there, we can't commit coding style changes (including whitespace) until after we've gotten the number of unreviewed patches down. I'll review this patch in a moment!
Comment #15
dsnopekOk! I tested and reviewed and made a couple of changes:
I've attached an updated patch and interdiff from the last patch. I ran the tests I thought would be affected locally and they succeeded! I'm going to commit in a moment so that the full test suite will run on Travis-CI.
Thanks so much to @whastings and @Andrew Edwards for your hard work on this patch!
Comment #17
dsnopekCommitted!
Let's see what Travis-CI has to say:
https://travis-ci.org/panopoly/panopoly/builds/29063701
Comment #19
Andrew Edwards CreditAttribution: Andrew Edwards commentedWoohoo! Thanks @dsnopek