[drupal-devel] [feature] Node module should provide node object to theme search hook

Eric Scouten drupal-devel at drupal.org
Sun Jan 23 22:49:30 UTC 2005


 Project:      Drupal
-Version:      4.5.0
+Version:      cvs
-Component:    page.module
+Component:    node.module
 Category:     feature requests
 Priority:     normal
 Assigned to:  Eric Scouten
 Reported by:  Eric Scouten
 Updated by:   Eric Scouten
 Status:       patch

Correcting version & component tags. Not sure how it got the wrong info
to begin with.

Eric Scouten



Previous comments:
------------------------------------------------------------------------

January 23, 2005 - 12:28 : Eric Scouten

Attachment: http://drupal.org/files/issues/node_search_hook.patch (719 bytes)

As currently defined node.module's search hook doesn't provide enough
information to allow a rich rendering of search results. For instance,
in a photographic web site, I'd like the search results to show a
thumbnail of each matched image. I can't do this without access to the
node object.

The attached one-line patch provides access to the node object in the
search results.

------------------------------------------------------------------------

January 23, 2005 - 13:55 : Anonymous

I assume you want the $node object in theme('search_item').

Another possibility is to change nodeapi('search result') so it can add
custom fields to the $item array rather than just being for adding
textual information to the result by-line. That way, the image.module
could add a 'thumbnail' field, which can be displayed in the theme.

The problem really is: does presentation of the search result belong in
the theme or in the modules? I'd like to avoid putting features like
search thumbnails in a theme, as a thumbnail adds more information
rather than just changing the way something is presented.

The current search API is still a bit of a mess, mostly because I
focused on functionality of the content search, and just did a minor
cleanup of the API code in my patch. Perhaps more invasive changes are
needed to allow truly rich search results?

------------------------------------------------------------------------

January 23, 2005 - 13:56 : Steven

Sorry, that was me.

------------------------------------------------------------------------

January 23, 2005 - 14:48 : Eric Scouten

Actually, for the particular site I was designing (not yet visible on
the Internet), I needed several pieces of information that were not
available to the search hook:


node's creation date, not the last updated date
node's teaser, not the text near the search term match
thumbnail for image nodes


I wouldn't expect the way I'm rendering search results to be desirable
for most sites, but it makes sense for this site, and the easiest way
to accomplish the desired rendering was to have the theme render the
node teaser rather than doing all kinds of image-specific additions.

I suspect I won't be alone in wanting to do node-specific rendering of
search results, so it seems reasonable IMHO to add the $node object to
the set of information provided for theme('search_item'). The attached
patch does exactly that and nothing more.

You wrote:

The problem really is: does presentation of the search result belong in
the theme or in the modules? I'd like to avoid putting features like
search thumbnails in a theme, as a thumbnail adds more information
rather than just changing the way something is presented.

As a matter of general principle, I agree with your argument that
Drupal as a whole is cleaner if the core (or the relevant node module)
does the heavy lifting of presenting search results and I am not
submitting any theme that would violate that principle. However, if
you're saying that Drupal should prevent a site designer from having
enough information to override the search results when the default
presentation isn't appropriate, then I strongly disagree with you.

-- 
View: http://drupal.org/node/16056
Edit: http://drupal.org/project/comments/add/16056





More information about the drupal-devel mailing list