Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-02-20 21:05:43

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
Website

<txp:if_search_results> doesn't work with chh plugin

Hi to all!

I wanted to have pagination on my search result page. And I thought chh_article will work fine, and in fact it does, but <txp:if_search_results> doesn’t work.

All I see is: “Sorry, we were not able to find a page matching your search request ..” Even when I see results

Here you have the code:

<txp:chh_article limit="15" section="search" />
<div id="navigation">
 <txp:if_individual_article>
  <div class="al"><txp:link_to_prev>« <txp:prev_title /></txp:link_to_prev></div>
  <div class="ar"><txp:link_to_next><txp:next_title /> »</txp:link_to_next></div>
 <txp:else />
  <div class="al"><txp:older>« <txp:text item="older" /></txp:older></div>
  <div class="ar"><txp:newer><txp:text item="newer" /> »</txp:newer></div>
 </txp:if_individual_article>
</div>
<txp:if_search_results>
 <p>These articles match your search request: </p>
<txp:else />
 <p>Sorry, we were not able to find a page matching your search request <strong><txp:search_term /></strong>.</p>
</txp:if_search_results>    

Any idea? There other problem is:

Example:

I got an article with the following terms: "Hello I'm a little dog"

If I try to find the text by: "little dog" (those words are next each other) I do find the article, but if I try the text: "hello dog" (the words are separate but int the same article) I cannot get any results…

What’s wrong? The search tag doesn’t work in that way?

Hope you can help me and understand me, because I’m spanish speaker.

Thanks in advance,
Robhert.

Offline

#2 2008-02-20 22:21:47

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

Re: <txp:if_search_results> doesn't work with chh plugin

You need a <txp:article /> tag to display search results. So you can do something like this:

<txp:if_search>
   <txp:if_search_results>
      <p>These articles match your search request: </p>
      <txp:article limit="15" />
   <txp:else />
      <p>Sorry, we were not able to find a page matching your search request <strong><txp:search_term /></strong>.</p>
   </txp:if_search_results>    
<txp:else />
   <txp:chh_article /><!-- your article tag for regular articles -->
</txp:if_search>

<div id="navigation">
<txp:if_individual_article>
   <div class="al"><txp:link_to_prev>« <txp:prev_title /></txp:link_to_prev></div>
   <div class="ar"><txp:link_to_next><txp:next_title /> »</txp:link_to_next></div>
<txp:else />
   <div class="al"><txp:older>« <txp:text item="older" /></txp:older></div>
   <div class="ar"><txp:newer><txp:text item="newer" /> »</txp:newer></div>
</txp:if_individual_article>
</div>

The search indeed doesn’t work that way. It only searches for exact matches. There is a plugin, that offers alternative suggestions, but it still doesn’t search for separate words like in your example.

Offline

#3 2008-02-20 23:21:43

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
Website

Re: <txp:if_search_results> doesn't work with chh plugin

Hi Els, thank you for your answer.

I did it. But all I see is Sorry, we were not able to find a page matching your search request "news".

What do you think is wrong?

Any idea?

Thanks for your help!

Robhert.

Offline

#4 2008-02-20 23:28:01

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

Re: <txp:if_search_results> doesn't work with chh plugin

Do you have the word ‘news’ in an article title or body?
Is/are the section(s) you want to be searched set to be included in the search (Presentation > Sections)?

Offline

#5 2008-02-20 23:44:15

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
Website

Re: <txp:if_search_results> doesn't work with chh plugin

Thanks for your anwer again Els.

Well, in fact I tried out with a lot of words that are in an article, title, body.

Just with one word like: “frozen”, “cool”, etc.

Nop. Sections are not included.

As I say, I saw the search results with my earlier script. But with your I see just ‘no result’

So I mean, the words I write into search box, already existe into my articles (body / title). So there’s no problem/trouble with keywords… Just with script.

Help me please.

Robhert

Offline

#6 2008-02-21 03:25:40

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

Re: <txp:if_search_results> doesn't work with chh plugin

Is/are the section(s) you want to be searched set to be included in the search (Presentation > Sections)?

Nop. Sections are not included.

That would be your problem then.

Offline

#7 2008-02-21 13:51:21

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
Website

Re: <txp:if_search_results> doesn't work with chh plugin

Hey!, Thanks for your answer again.

I’m sorry. I don’t know what I was thinking… Sections are included! All sections of my site are included on the search.

And as I said, I can search in my site with my previously script (see #1) But the problem is tag <txp:if_search_results> doesn’t appear to be working. All the time I see is: Sorry, we were not able to find a page matching your search request .. Even when I get results!! That’s why I asked that question on the forum.

I tried out the script solution in #2 but it doesn’t work for me.

Any idea else?

Thanks for your time and patience.

Robhert.

Last edited by robhert (2008-02-21 13:54:10)

Offline

#8 2008-02-21 18:25:25

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

Re: <txp:if_search_results> doesn't work with chh plugin

robhert wrote:

And as I said, I can search in my site with my previously script

Then the problem must be in my code, I’m probably overlooking something. Could you replace the first part with this:

<txp:if_search>
   <txp:if_search_results>
      <p>These articles match your search request: </p>
   <txp:else />
      <p>Sorry, we were not able to find a page matching your search request <strong><txp:search_term /></strong>.</p>
   </txp:if_search_results>
   <txp:article limit="15" />
<txp:else />
   <txp:chh_article /><!-- your article tag for regular articles -->
</txp:if_search>

and let me know if it works?

Offline

#9 2008-02-21 18:41:26

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

Re: <txp:if_search_results> doesn't work with chh plugin

Robhert,

not sure why you are working with <txp:chh_article limit="15" />.
But some TxP search tags need the search/results to be paginated before working (don’t know how to explain it exactly in english).
In fact, <txp:if_search_results> needs that.

So, you have to add a <txp:article limit="15" pgonly="1" /> somewhere (wherever you want) above your search tags. This tag will do the query to TxP database, but won’t output anything on the front-end. It has to be exactly as your other txp:article tag (chh_article, in this case) and have the pgonly="1" attribute added.

Try it.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#10 2008-02-21 18:56:03

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

Re: <txp:if_search_results> doesn't work with chh plugin

That is what I overlooked! Thanks Julián :) So this should work:

<txp:if_search>
   <txp:article limit="15" pgonly="1" />
   <txp:if_search_results>
      <p>These articles match your search request: </p>
   <txp:else />
      <p>Sorry, we were not able to find a page matching your search request <strong><txp:search_term /></strong>.</p>
   </txp:if_search_results>
   <txp:article limit="15" />
<txp:else />
   <txp:chh_article /><!-- your article tag for regular articles -->
</txp:if_search>

Offline

#11 2008-02-21 19:12:46

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
Website

Re: <txp:if_search_results> doesn't work with chh plugin

I’m very grateful with you Els for your patience and your support.

Your code works but with a little “change”, when you want to <txp:if_search_results> tag works, you have to put it below the <txp:article /> tag see: forum

So, here it goes:

<txp:article limit="15" />
<txp:if_search>
 <txp:if_search_results>
  <p>These articles match your search request: </p>
 <txp:else />
  <p>Sorry, we were not able to find a page matching your search request <strong><txp:search_term /></strong>.</p>
 </txp:if_search_results>
<txp:else />
 <txp:chh_article /><!-- your article tag for regular articles -->
</txp:if_search>
<div id="navigation">
 <txp:if_individual_article>
  <div class="al"><txp:link_to_prev>« <txp:prev_title /></txp:link_to_prev></div>
  <div class="ar"><txp:link_to_next><txp:next_title /> »</txp:link_to_next></div>
 <txp:else />
  <div class="al"><txp:older>« <txp:text item="older" /></txp:older></div>
  <div class="ar"><txp:newer><txp:text item="newer" /> »</txp:newer></div>
 </txp:if_individual_article>
</div>	    

But, I still have some question…

1) Why or, what should I do to see: These articles match your search request: above the results?’

Because, once I get the results, I see These articles match your search request: below all resuts, and.. it doesn’t have sense… right?

2) How can I change the format <txp:search_result_date /> Because, within the first 15 results, I see: 150 days ago and the next results are like this: mar 2, 21:15 … So I want to change this. I ant to change the way it looks. Any idea?

Thanks you again. And thanks in advance for it.

Regards,
Robhert.

Last edited by robhert (2008-02-21 19:13:43)

Offline

#12 2008-02-21 19:39:50

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

Re: <txp:if_search_results> doesn't work with chh plugin

robhert wrote:

1) Why or, what should I do to see: These articles match your search request: above the results?’
Because, once I get the results, I see These articles match your search request: below all resuts, and.. it doesn’t have sense… right?

Did you see Maniquí’s reply and my post after his? I corrected the code I first gave to you in that.

2) How can I change the format <txp:search_result_date /> Because, within the first 15 results, I see: 150 days ago and the next results are like this: mar 2, 21:15 … So I want to change this. I ant to change the way it looks. Any idea?

It uses the date format you’ve set in Admin > Preferences. You can change ‘Date format’. If you set it to ‘hrs/days ago’, this will only be used for the articles on the front page. Next pages use the ‘Archive date format’, so you would have to set both to the same format.

Offline

Board footer

Powered by FluxBB