I’m going to make one more comment here, after some hours in attempting a solution for what Mr. Wilson emphatically wants (of Dennis).
Summary: it’s really not a good idea to go against the intended design of EE, most especially where this is old design, from back where many things were automatic to help designers who were not particularly developers.
Corollary: EE is not a computationally complete language system, which would allow free use of logic (“programming”), unless you want to go to using embedded PHP. You are much better off considering it a declarative language, and using its features as intended.
I attempted to find a way to use conditions to form a single template for both search_found and no_results cases. In the end, this is very messy no matter what avenue you try, and doesn’t work. Here are the most relevant attempts.
1. I tried simple if statements. Failed because of parse order. Would fail anyway, as later discovered that even though the general rule is that false conditioned statements don’t get parsed, apparently in the search tags case they do, and you run then into what Mr. Wilson doesn’t want, the protect-new-users system search not found screen.
2. I tried simple if statements in an embed, passing across the available value of total_results. This fails: runs into the same problem that somehow the search_results tag is parsed, even though it’s provably conditioned out (using flag strings to identify that the if statement works)
3. I put the if statements, zero and some results, back in the top level, and put the search_results tag in an embed. Now I get the correct output from template in either found or no results case. However, here, there is a pretty impossible situation with the system lang tags. They are automatically correlated to the presence of their matching tag, exp:search_results in this case. You have then to have them in the embed template, to get them parsed and proper strings on screen. At this point, you’ve written just what you don’t want to: a second page.
My thinking then is this. It’s a lesson how this doesn’t work, and the lesson is to use EE with its best face showing. That means collapsing your DRY work at much higher levels, using the improved parsing snippets etc. to write the layout for all but the data on your page. Then in a case like search, use the anciently written search tag as it was intended. Produce the two results pages, which have identical full page layout from snippets, and only the content area changed. You can do it in a moment if you write one of them first, then create a new template copying the first, followed by a quick edit.
As mentioned before, you have the chance then to put in any other nice layout you want, on top of basics. A search not-found often benefits quite a lot from a gentle or humorous graphic. As in the conversation here, people react a lot better if they don’t think you’re telling them they’re wrong.
I can’t really see a case for changing the original search tag, as it protects anyone who doesn’t get into the intricacies, giving the system no-results if you don’t do it right. That’s good for someone new to EE, and then they can learn to do something more attractive.
If such a change were made, I would suggest it be done with an extra parameter, defaulted to present behaviour.
I find the documentation correct about the main matter here. In fact, it suggests which tags you can use in the no-results page, if you read that far. I did find one separate error, in definition of {exp:search:total_results}. It’s actually a single tag, rather than a value on a double tag. I’ll report that.
Why do this work? I wanted to be sure of practice that works, for this kind of thing. Good practice goes a long way, with a powerful system floating above very complicated, complex systems, which well used lets even experts achieve a lot more than they otherwise would.
Regards,
Clive