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.
Use case
node module has article and page as bundles. for the bundle article you create a view mode called search result, but for the bundle page you don't. Now, since you haven't enabled this on the entity level, but on a per bundle level it doesn't show in the views configuration. See https://www.evernote.com/shard/s44/sh/cbbcaf72-623c-4cb3-98ba-d668483746...(Index-Search-API-Database-Index)---Site-Install.png
We need to fix this so we can mimic core search easily.
Comment | File | Size | Author |
---|---|---|---|
#18 | 2471669-18--bundle_view_modes--interdiff.txt | 8.7 KB | drunken monkey |
#18 | 2471669-18--bundle_view_modes.patch | 14.71 KB | drunken monkey |
#6 | 2471669-6.patch | 9.03 KB | Nick_vh |
#5 | 2471669-5.patch | 9.13 KB | Nick_vh |
#4 | 2471669-4.patch | 9.32 KB | Nick_vh |
Comments
Comment #1
Nick_vhComment #2
Nick_vhCurrently blocked by #2322503: getDisplayModeOptions() returns only full or teaser regardless of the status of the entity display.
Comment #3
Nick_vhMaking good progress in the core issue. Going to set this to needs work as we can almost rely on that patch
Comment #4
Nick_vhComment #5
Nick_vhComment #6
Nick_vhComment #9
Nick_vhComment #10
Nick_vhComment #13
Nick_vhComment #14
drunken monkeyThanks, looks like a good start!
However, a there are still some problems with your patch:
With that structure, won't you run into problems if two entity types have bundles with the same name?
I think the structure should be:
$options['view_modes'][$datasource_id][$bundle] = $view_mode
(where$bundle
might beNULL
).This should have a leading "(optional) " in the description, and also explain what should be done for
NULL
(since I'm not sure myself). Is it only called that way when a datasource has no bundles? Or should it return the bundle-independent view modes?This looks like it's just been copied from the content entity datasource? It should be rephrased to reflect the general approach that the datasource "provides" or "contains" bundles, not indicate that the datasource might only contain a subset of available bundles.
Seems to have slipped in?
Does this always work? Also for entity types without bundles or config entities?
This doesn't seem to make sense? According to the documentation, this should return just the IDs. (Though returning IDs mapped to labels would make much more sense, I think it should do that.)
But then, of course, all the wrapping
array_keys()
calls don't make sense. It seems like you stopped half-way in implementing my suggestion of returning an ID-label map.It's debatable whether we want to keep that comment, but in any case it shouldn't be part of this issue.
This should be in one line, as anywhere else.
Comment #15
Nick_vhUpdated. Please review :)
re: #5 - this is always true. Addressed all other comments I think.
Comment #16
Nick_vhdrunkenmonkey - please add this to the patch while you are reviewing or changing it. Otherwise I'll reroll it later
Comment #18
drunken monkeyAll reviewing and no coding makes Thomas a dull boy.
Comment #19
Nick_vhGo for it!
Comment #20
drunken monkeyCommitted.
Thanks again!
Comment #23
tstoecklerOpened follow-up: #2471669: Views should show the view mode for each bundle as view modes are configured per bundle
Comment #24
tstoecklerOops, I meant #2483879: Bundle select in"Rendered Search API item" has broken label.