Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-02-05 14:35:07

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

if_search_results always false

Trying out the new if_search_results tag, it is always returning false. I made a stripped-down test page; here is the tag trace on a search results page returning one article:

<txp:output_form form="doctype" />
	[SQL (0.000573): select Form from txp_form where name='doctype']
	[Form: doctype]
<txp:output_form form="head" />
	[SQL (0.001707): select Form from txp_form where name='head']
	[Form: head]
	<txp:css format="link" media="all" />
	<txp:site_url/>
	<txp:page_title/>
	<txp:site_url/>
<txp:if_search>
	[<txp:if_search>: true]
</txp:if_search>
<txp:if_search_results>
	[<txp:if_search_results>: false]
</txp:if_search_results>
<txp:article limit="5" />
	[SQL (0.000718): select name from txp_section where searchable != '1']
	[SQL (0.011583): select count(*) from textpattern where 1=1 and Status = 4 and Posted <= now() and (Title rlike 'caper' or Body rlike 'caper') ]
	[SQL (0.012426): select *, unix_timestamp(Posted) as uPosted, match (Title,Body) against ('caper') as score from textpattern where 1=1 and Status = 4 and Posted <= now() and (Title rlike 'caper' or Body rlike 'caper')  order by score desc limit 0, 5]
	[article 14]
	[SQL (0.000565): select Form from txp_form where name='search_results']
	[Form: search_results]
	<txp:permlink>
		<txp:title/>
	</txp:permlink>
	<txp:search_result_excerpt/>
	<txp:permlink>
		<txp:permlink/>
	</txp:permlink>
	<txp:posted/>
<txp:older>
</txp:older>
<txp:newer>
</txp:newer>

Have I made a mistake or is this a possible bug?


Code is topiary

Offline

#2 2008-02-05 14:50:07

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: if_search_results always false

Not sure because I haven’t tested 4.0.6 yet, but try adding a <txp:article limit="5" pgonly="1" /> somewhere above your if_search tag.
It won’t output anything, but just do some internal TxP black magic.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2008-02-05 15:09:57

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

Re: if_search_results always false

^^ correct. The if_search tags have to be used below a txp:article tag, because that tag performs the actual search and before that happens, the number of search results is not known.

Offline

#4 2008-02-05 15:10:06

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: if_search_results always false

maniqui wrote:

Not sure because I haven’t tested 4.0.6 yet, but try adding a <txp:article limit="5" pgonly="1" /> somewhere above your if_search tag.
It won’t output anything, but just do some internal TxP black magic.

Well, it works. And if I simply put the if_search_results tag below the normal article tag, that works too. Thanks — I guess a note should be added to the if_search_results entry on Textbook?


Code is topiary

Offline

Board footer

Powered by FluxBB