Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-03-08 11:37:37

Lucanos
Member
From: Sydney, Australia
Registered: 2006-01-17
Posts: 23
Website

Solution - "No Records Found" Message

Hey everyone,

Not sure whether anyone has a better solution than this one, but it’s something I cobbled together after searching (unsuccessfully) for a pre-built solution online…

I wanted to create a message to be displayed whenever a search is performed, but fails to return any records. The default action (at least on my TextPattern site) was just an empty DIV where the records normally appear.

The following is inserted into the appropriate page (in my case “default”), just above the <code><txp:article… /></code> tag through the use of the <code><txp:output_form… /></code> tag.

<code><!— txp:if_search —> <txp:if_search> <!— TRUE —> <div class=“search_result_count”> <txp:php> if ( search_result_count ( array ( text=>”“ ) ) == “” ) { // No Records Found echo “No Records Found”; } else { // Records Found echo search_result_count ( array ( text=>”“ ) ); } </txp:php> </div> <txp:else /> <!— FALSE —> </txp:if_search>
<!— /txp:if_search —></code>

Whilst I am kind of happy with the fact that I am starting to stretch my understanding of TXP, as I am still very much a novice, I was wondering whether anyone out there had made anything like this previously?

If so, can you share your (no doubt more elegant) solution?

Also, as a side note, I tried to format this post as closely to the standard as possible, with the “code” tags. Is there a better way to use them than how I have above?

Offline

#2 2006-03-08 14:19:02

23:59:59
New Member
From: a clock near you
Registered: 2006-01-25
Posts: 6
Website

Re: Solution - "No Records Found" Message

I saw a thread on this a few weeks ago, I think this is it.

Last edited by 23:59:59 (2006-03-08 14:20:23)

Offline

#3 2006-03-08 17:50:16

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Solution - "No Records Found" Message

You can also use the plugin chh_if_data.

Offline

#4 2006-03-09 01:41:29

Lucanos
Member
From: Sydney, Australia
Registered: 2006-01-17
Posts: 23
Website

Re: Solution - "No Records Found" Message

So many tricks…
Still so much to learn (on my part).

Thanks for your help guys.

PS – My initial solution is nowhere near as clean as I would have hoped. So anyone reading this thread looking for a quick-fix, keep looking.

Offline

#5 2006-03-09 02:03:29

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Solution - "No Records Found" Message

I always just used: <txp:search_result_count />, does it matter if it says “no” instead of “0”?

Offline

Board footer

Powered by FluxBB