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

Eric Scouten drupal-devel at drupal.org
Wed Jul 27 03:53:05 UTC 2005


Issue status update for 
http://drupal.org/node/16056
Post a follow up: 
http://drupal.org/project/comments/add/16056

 Project:      Drupal
 Version:      cvs
 Component:    node.module
 Category:     feature requests
 Priority:     normal
 Assigned to:  Eric Scouten
 Reported by:  Eric Scouten
 Updated by:   Eric Scouten
 Status:       patch
 Attachment:   http://drupal.org/files/issues/node.module_10.patch (788 bytes)

Once again... in unidiff format.




Eric Scouten



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

Sun, 23 Jan 2005 20:28:21 +0000 : 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.




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

Sun, 23 Jan 2005 21:55:42 +0000 : 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?




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

Sun, 23 Jan 2005 21:56:09 +0000 : Steven

Sorry, that was me.




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

Sun, 23 Jan 2005 22:48:19 +0000 : 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.




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

Sun, 23 Jan 2005 22:49:24 +0000 : Eric Scouten

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




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

Sun, 13 Mar 2005 20:40:29 +0000 : killes at www.drop.org

Doesn't apply anymore.




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

Mon, 25 Jul 2005 05:33:52 +0000 : Eric Scouten

Updating patch. (It's just a one-liner, BTW... can it be that hard to
figure out if node.module changes again?)







More information about the drupal-devel mailing list