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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Title: AlterItems only on Index not on search » Alter items only on index not on search
Component: Code » Search pages

Probably, 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.

Anonymous’s picture

Or an $index->state 'index', 'search', ...

then you can deside to alter only on $index->state == 'index'

drunken monkey’s picture

Title: Alter items only on index not on search » Overhaul display of search results
Status: Active » Needs review
FileSize
7.53 KB

OK, 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!

Anonymous’s picture

You 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

drunken monkey’s picture

What 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?

Anonymous’s picture

Works super!

Greets

Tim

drunken monkey’s picture

Status: Needs review » Fixed

Thanks for the feedback, and the initial push.
Just committed this, a new beta release will follow in the next few days.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.