Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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
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.
Offline
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
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
Pages: 1