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.
Hey
As mentioned before, I think AlterItems should only be fired on index, not on search, because the altered items are indexed, you would already search on the altered variation/custom field instead of the original value.
Because for example the document search, gets the content from files on index and this is stored in a custom field. This process takes a while, so to fire it again on search is a no go.
Or there should be a way to check if you are in "search" or "index" - mode
Greets
Tim
Comment | File | Size | Author |
---|---|---|---|
#5 | search_api_page.display_overhaul.patch | 7.44 KB | drunken monkey |
#3 | search_api_page.display_overhaul.patch | 7.53 KB | drunken monkey |
Comments
Comment #1
drunken monkeyProbably, the whole display of the search results should be overhauled — e.g. by using
entity_view()
and maybe letting users choose the view mode. I agree that calling data alterations when displaying a search results was probably a poor decision.Anyone else want to comment on this?
Otherwise I'll fix this either specifically, or rewrite the whole search result theming, probably in about a week or so.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedOr an $index->state 'index', 'search', ...
then you can deside to alter only on $index->state == 'index'
Comment #3
drunken monkeyOK, I opted for doing the complete overhaul, took less than an hour anyways. It is now possible to use any view mode for the entity to display search results, as well as the built-in theme function. The latter also now doesn't call the data alterations, and respects
$result['excerpt']
(as defined by the query class), if set.Please review!
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedYou have added a build mode selection on the search page admin, this however doesn't do anything, and i'm not sure if this is necessary. I think themed search result is more then enough.
For the alterItems in search / index this works fine
Regards
Tim
Comment #5
drunken monkeyWhat do you mean, "it doesn't do anything"? It does exactly what it's supposed to do: search results are displayed in the selected view mode, which gives a lot more flexibility. Even if you personally don't need that flexibility.
There was, however, a little bug in the edit form, that I've fixed in the attached updated patch.
Any other comments, before I commit this?
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedWorks super!
Greets
Tim
Comment #7
drunken monkeyThanks for the feedback, and the initial push.
Just committed this, a new beta release will follow in the next few days.