Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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
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
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
.
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
Re: Categorised Search Results
Exactly like that! Thanks a lot Els, it works just as I had hoped :)
Offline
Pages: 1