In the search_data function, theme('search_page') gets called if there are search results, but not if there are no search results.

I'm not sure if this was intentional, but the end result seems to be that it's not possible to theme the page corresponding to no search results without a very ugly override of theme_box.

Comments

Wesley Tanaka’s picture

Status: Active » Needs review
StatusFileSize
new606 bytes
Wesley Tanaka’s picture

StatusFileSize
new1013 bytes

same patch as above, but with a clarifying comment on theme_search_page

drumm’s picture

Version: 5.x-dev » 6.x-dev
Status: Needs review » Needs work

Theme API changes are only going to happen in development versions of Drupal. There might be time for 6.x, but it is already in code freeze.

The method of override does not seem logical to me. I would expect a separate theme function to be called for the no results page.

douggreen’s picture

Version: 6.x-dev » 7.x-dev
Category: bug » feature
Status: Needs work » Needs review
StatusFileSize
new611 bytes

I've rerolled this patch for 7.x simplifying it a little. I'm not sure that I agree with drumm that this needs to be it's own theme function. So, I've taken the simplest possible solution. This adds two lines of code, and in the HTML, it should add an empty <dl> </dl>

douggreen’s picture

This is closely related, if not a duplicate of #211141: Add ability to customize display if search from block has no keywords entered, and they should be worked together. If you're going to close one of this issues, it should probably be the other one, as this one already has a patch.

Status: Needs review » Needs work

The last submitted patch failed testing.

lilou’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch failed testing.

WorldFallz’s picture

Category: feature » bug
Status: Needs work » Needs review
StatusFileSize
new2.72 KB

"no results" is a valid search result and the fact that this one particular search result is hard coded into search.module is a bug imo.

Here's an updated patch that addresses this more completely.

dww’s picture

Status: Needs review » Needs work

Note, this is related to #242048: Replace "blue smurf" in no search results message but distinct. Yes, it's lame the default help text in D6 and earlier mentioned "blue OR smurf" etc. It's a step in the right direction that it's now "bike OR shed". However, it's lame this text is still hard-coded into core at all via help text. It'd be a lot better if this message was controlled by a theme function so you could change it to "Karl OR Marx" if you wanted to without hacking core.

This patch would at least allow a theme to provide its own search-results.tpl.php file and not invoke print search_help('search#noresults', drupal_help_arg()); if it didn't want to.

Big +1 from me. However, the current patch includes <h2>Search Results</h2> without t() in the default template, which is obviously a no-no.

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new2.95 KB

In addition to the t() for the "Search results" header, I also fixed the logic in the search-results.tpl.php file so that if we're in the "no results" case, we don't print the <dl> or the pager.

dave reid’s picture

Status: Needs review » Reviewed & tested by the community

Great cleanup.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks!

dww’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Needs review
StatusFileSize
new2.8 KB

D6 backport. Tested and working nicely.

jhodgdon’s picture

Version: 6.x-dev » 7.x-dev
Status: Needs review » Fixed

This is a large functionality change for Drupal 6. I think it's a won't fix for Drupal 6 (see #3 above).

jhodgdon’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Needs review

dww thinks maybe we should let Gabor decide on whether it's OK for D6 or not, and I'm certainly OK with that idea.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

The patch looks OK to me (basically same as D7 functionality)

gábor hojtsy’s picture

Version: 6.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Fixed

I agree this would be nice and all but the way it modifies the search template now making it responsible to output the page title will break many sites who did override this function or use a base theme which did override this function. Unfortunately this breaks backward compatibility in a non-trivial way. Moving back to D7 fixed.

Status: Fixed » Closed (fixed)

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