Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-09-09 06:46:33

husainhk
Member
From: Dubai, UAE
Registered: 2007-08-12
Posts: 105
Website

Categorised Search Results

Hello All,

I have a large number of article categories and would like to structure the results, category-wise, like:

Your search term “blah” has found 50 articles.

Cateogry 1
Article 1
Article 2
Article 3
Article n

Cateogry 2
Article 1
Article 2
Article 3
Article n

Cateogry 3
Article 1
Article 2
Article 3
Article n

… and so on …

Any pointers?

Offline

#2 2010-09-09 08:41:00

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,254
Website GitHub Mastodon Twitter

Re: Categorised Search Results

Any pointers?

Something like

<txp:if_search_results>
<txp:article_custom category='<txp:category />'>
<a href="<txp:search_result_url>".<txp:search_result_title /></a>
</txp:article_custom>
</txp:if_search_results>

to start you off with.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2010-09-09 13:32:59

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

Re: Categorised Search Results

Also, I think you will have to sort them by category

<txp:if_search_results>
<txp:article_custom category='<txp:category />' sort="Category asc">
<a href="<txp:search_result_url>".<txp:search_result_title /></a>
</txp:article_custom>
</txp:if_search_results>

To add the Category headings as separators, take a peek at txp:if_different.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#4 2010-09-09 17:43:40

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

Re: Categorised Search Results

Hmm you two… don’t we need a <txp:article /> tag to display search results, or did I only dream that?

Husain, if I understand you correctly, you want to do something like this?

<txp:if_search>
   <txp:article pgonly="1" sort="Category1 asc, Posted desc" limit="999" />
   Your search term "<txp:page_url type="q" />" has found <txp:search_result_count text="articles" />.
   <txp:article sort="Category1 asc, Posted desc" limit="999">
      <txp:if_different><txp:category1 title="1" /></txp:if_different>
      <txp:search_result_title />
   </txp:article>
</txp:if_search>

Offline

#5 2010-09-12 12:44:04

husainhk
Member
From: Dubai, UAE
Registered: 2007-08-12
Posts: 105
Website

Re: Categorised Search Results

Exactly like that! Thanks a lot Els, it works just as I had hoped :)

Offline

Board footer

Powered by FluxBB