Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: ... display a message whether search result returns no match found
oh, cool!
Still get “Sorry, no match found for your request.” on seraches that return results, though.
Yes, I have tried turning it off and on.
Offline
Re: ... display a message whether search result returns no match found
Would you mind sharing the exact sequence of tags and php code starting from <txp:if_search>
up to the closing </txp:if_search>
you are using? Use pastebin if you feel like Textile is fighting against you when you post code here.
Offline
Re: ... display a message whether search result returns no match found
<txp:if_search>
<div class="line"> </div>
<p><txp:php>
global $thispage; global $q;
echo( ($thispage['total']==0 ?
"Sorry, no match found for your request." :
"Your search for <strong>$q</strong> resulted in ".$thispage['total']." hits." ) );
</txp:php></p>
</txp:if_search>
the page is here
Last edited by alesh (2006-02-20 19:07:25)
Yes, I have tried turning it off and on.
Offline
Re: ... display a message whether search result returns no match found
Ok, alright. The other precondition for this code to work properly which you have missed is that it must be preceded by a call to <txp:article />
, as the match count is calulated by code which is executed by the <txp:article>
handler.
You can use an additional <txp:article pgonly="1" />
tag preceding the <txp:if_search> ... sorry, no matches.. </txp:if_search>
sequence if you do not want to change the display sequence you are using now:
<txp:article pgonly="1" /> <!-- just calculate global article properties, suppress any display -->
<txp:if_search>
[...]
</txp:if_search>
<txp:article /> <!-- do display stuff here -->
Phew. That’s a hard one, but I think we are almost there…
Last edited by wet (2006-02-20 19:50:22)
Offline
Re: ... display a message whether search result returns no match found
ah. why couldn’t it go inside the if_search ? that way I don’t have a whole extra rutine call on every page load… it still preceeds the php, right?
Yes, I have tried turning it off and on.
Offline
Re: ... display a message whether search result returns no match found
Right, that will work and save some energy ;-) The only thing to obey is that a call to <txp:article />
has to precede all that php code.
Last edited by wet (2006-02-20 19:41:21)
Offline
Re: ... display a message whether search result returns no match found
Perfect; thanks!
Quibble: you’re missing the slash from the “dummy” article tag before. For some reason, that made it not work for searches with >0 results. Otherwise, it’s brilliant.
Although this just makes me realize I have a lot of other work to do on my search results page . . .
Yes, I have tried turning it off and on.
Offline
Re: ... display a message whether search result returns no match found
> alesh wrote:
Quibble: you’re missing the slash from the “dummy” article tag before.
O o. Corrected for posterity . . .
Offline
#21 2006-02-20 19:46:47
- stonesuit
- New Member
- Registered: 2006-02-20
- Posts: 3
Re: ... display a message whether search result returns no match found
Excellent! It works for me just fine. Thanks, wet.
Offline
#22 2006-02-20 22:42:54
- Luxebot
- Member
- From: Los Angeles
- Registered: 2006-02-18
- Posts: 25
Re: ... display a message whether search result returns no match found
Now it works! Thank you very much! :)
Offline
Re: ... display a message whether search result returns no match found
Hi,
Is it possible to have the search results html output in three different ways ? That’s what I’m trying to do :
- no results outputs a paragraph,
- one result outputs a header followed by a paragraph,
- two or more results outputs a list.
Thanks
man-d
Offline
Re: ... display a message whether search result returns no match found
meb: <code>You searched for “<txp:php>echo htmlspecialchars(gps(‘q’));</txp:php>”.</code>
Offline