Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-12-15 03:34:43

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

if_search_results returns false

Perhaps I’m misunderstanding the tag, but <txp:if_search_results> returns false when there are search results. I’m on r2749. Search results display, but if_search_results is never true.

default page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en-us" xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><txp:page_title /></title>
</head>
<body>
	<txp:search_input />

	<txp:if_search>
		<txp:if_search_results>
			<p><txp:search_result_count /> found for &#8220;<txp:search_result />&#8221;</p>
		<txp:else />
			<p>No results found.</p>
		</txp:if_search_results>
	</txp:if_search>

	<txp:article />
</body>
</html>

Tag trace for txp.dev/?q=lorem:

<!-- Runtime:    0.0168 -->
<!-- Query time: 0.005265 -->
<!-- Queries: 11 -->
<!-- Memory: 3436Kb, <txp:posted> -->
<!-- txp tag trace: 
[SQL (0.002286): select name, data from txp_lang where lang='en-gb' AND ( event='public' OR event='common')]
[SQL (0.000217): select name,code,version from txp_plugin where status = 1 AND name='releases']
[SQL (0.000421): select name, code, version from txp_plugin where status = 1]
[SQL (0.000210): select * from txp_section where name = 'default' limit 1]
[SQL (0.000154): select user_html from txp_page where name='default']
[Page: default]
<txp:lang/>
<txp:lang/>
<txp:page_title/>
<txp:search_input/>
	[SQL (0.000121): select form from txp_form where `name` = 'search_input' limit 1]
<txp:if_search>
	[<txp:if_search>: true]
	<txp:if_search_results>
		[<txp:if_search_results>: false]
	</txp:if_search_results>
	<txp:article/>
		[SQL (0.000197): select name from txp_section where searchable != '1']
		[SQL (0.000317): select count(*) from textpattern where 1=1 and Status = 4 and Posted <= now() and (Title rlike 'lorem' or Body rlike 'lorem') ]
		[SQL (0.000562): select *, unix_timestamp(Posted) as uPosted, match (Title,Body) against ('lorem') as score from textpattern where 1=1 and Status = 4 and Posted <= now() and (Title rlike 'lorem' or Body rlike 'lorem')  order by score desc limit 0, 10]
		[article 1]
		[SQL (0.000145): 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:if_search>
[ ~~~ secondpass ~~~ ]
 -->

Offline

#2 2007-12-15 12:18:34

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

Re: if_search_results returns false

You have to put the if_search_results tag below the article tag, because the article tag does the search, so before it is not known if and how many search results there are.

btw, txp:search_result does not exist as a tag.

Offline

#3 2007-12-16 10:23:27

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

Re: if_search_results returns false

Or, use a second article tag with the pgonly attribute.

Offline

#4 2007-12-17 05:36:58

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: if_search_results returns false

Thanks. Search and pgonly always trips me up.

btw, txp:search_result does not exist as a tag.

D’oh! I have <txp:search_term /> in the developing site, but that didn’t get translated to my vanilla install’s page template.

Offline

Board footer

Powered by FluxBB