Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2006-02-20 18:47:22

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

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

#14 2006-02-20 18:58:05

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,354
Website GitHub Mastodon

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

#15 2006-02-20 19:04:15

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

Re: ... display a message whether search result returns no match found

<txp:if_search>
<div class="line">&nbsp;</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

#16 2006-02-20 19:24:08

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,354
Website GitHub Mastodon

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

#17 2006-02-20 19:26:31

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

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

#18 2006-02-20 19:30:44

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,354
Website GitHub Mastodon

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

#19 2006-02-20 19:37:39

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

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

#20 2006-02-20 19:45:28

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,354
Website GitHub Mastodon

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

#23 2006-04-13 04:27:34

man-d
Member
From: Montréal
Registered: 2005-10-25
Posts: 81
Website

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

#24 2006-09-08 17:07:42

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

Board footer

Powered by FluxBB