adding something to search display?
| Project: | Core searches |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
I need to display some links beneath each search result (see attached picture). The links need to contain the nid for each search result. I found the search result template (modules/search/search-results.tpl.php) and the file that creates variables used by the search result template (modules/search/search.pages.inc). I am using a theme which contains its own search results template, which apparently overrides the one in core. So again, what I need is simply to have the raw nid so that I can make more links on the search results page for each search result.
I found a couple of ways to get what I need:
* hack core (modules/search/searc.pages.inc) to extract the nid from the url just before it calls the search results template for each row. As we all know it is very bad practice to hack core. I am somewhat new to Drupal and I want to play by the rules.
* write a standalone function to extract nid from the URL (which IS returned as part of the search results), include_once on the search results page, and call the function on the display template for each row. But that creates two problems: 1) puts logic in the view, and 2) makes the enhancement very brittle (what if someone disables clean URLs or changes the theme?)
As far as I can tell, the search results page is not governed by views, else I'd have this done already.
Since I will be moving on soon and non-developers will be maintaining this site, I'd really prefer to do this with as little code as possible, preferrably even through views. I do not want to create an enhancement that can be broken or overwritten by performing basic site maintenance like upgrading a module or a theme. And as I said, hacking core is really undesirable.
Any ideas how I can, in the least invasive way possible, customize the search results page? Or is this just an impossibility given the constraints outlined above? Any help or guidance would be appreciated.
| Attachment | Size |
|---|---|
| results.png | 15.74 KB |
