I am trying to let my panelized entities get indexed for search. What seemed intuitive to me was to enable the "Search index" view mode on the entity type in question, and then panelize this view mode, substituting it with "Full page override".
However, when I index my content, the "Full page override" view mode (ie., page_manager) is never used. It always uses Default instead.
I think this is because in PanelizerEntityDefault::get_view_mode(), "page_manager" is not found in the "view mode status" array. Perhaps that's because in panelizer_entity_plugin_process() the "page_manager" view mode is assigned after the "view mode status" array is built.
I understand the page_manager view mode is sort of special, so I'm not sure how to resolve this. We could either add special handling in PanelizerEntityDefault::get_view_mode() for the page_manager view mode, or define that view mode earlier in panelizer_entity_plugin_process(). But I don't know what ramifications this will have.
Can you provide any insights on how to replace the search_index view mode with the rendered contents of the page_manager view mode?
Comment | File | Size | Author |
---|---|---|---|
#15 | panelizer-n2472519-15.interdiff.txt | 2.37 KB | DamienMcKenna |
#15 | panelizer-n2472519-15.patch | 8.77 KB | DamienMcKenna |
|
Comments
Comment #1
joelstein CreditAttribution: joelstein commentedThe following code in a custom module also does the trick, in case anyone needs this right away. But I still think this is a bug, since you are able to substitute search_index with page_manager in the UI, so it should also work in the code.
Comment #2
joelstein CreditAttribution: joelstein commentedThere are several problems with search and Panelizer, but I think for now we can limit this issue to one very specific bug.
In PanelizerEntityDefault::get_view_mode(), if no view mode is found and the fallback 'default' is assigned, we should check if 'default' is configured to be substituted, since this is possible in the UI:
The attached patch fixes this.
Comment #3
joelstein CreditAttribution: joelstein commentedComment #4
joelstein CreditAttribution: joelstein commentedThe previous patch still wouldn't allow to substitute non-default view modes with 'page_manager', because 'page_manager' is not configured in the 'view mode status' array.
One solution is to add 'page manager' to that array in panelizer_entity_plugin_process(), which may still be a good idea.
But by simply re-arranging PanelizerEntityDefault::get_view_mode() to fallback to default first, then check for the substitute, we actually resolve both issues: 1) we can substitute when falling back to the default view mode, and 2) we can substitute any view mode with 'page_manager'.
Comment #5
DamienMcKennaComment #6
DamienMcKennaWill work on a test for this tomorrow.
Comment #7
DamienMcKennaA patch with some tests to show that the bug exists.
Comment #8
DamienMcKennaBoth patches combined. In theory this should work.
Comment #11
DamienMcKennaThis should solve the problem. And I rewrite the logic a little bit to use get_substitute().
Comment #12
DamienMcKennaSome other changes accidentally slipped into #11.
Comment #15
DamienMcKennaCaught the problem - the tests had to pass additional arguments to the content type edit form in order to enable the substitute option.
Comment #17
DamienMcKennaCommitted.