Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-04-18 18:04:57

nostrich
New Member
Registered: 2008-04-15
Posts: 4
Website

Search result(s)

This might be a simple query, but I haven’t been able to locate an answer.

I’m using txp:search_result_count to display the number of results found, with text="result(s)". (As seen here My question is: is there any way to be able to automatically recognise if there’s 1 result, and thus display “result”, or more, and thus display “results”?

Another unrelated question (sorry, this should probably be in a separate topic): is there any way to change the default output of txp:article? At the moment, the default seems to be 10 articles, but I’d like it to display all articles instead. I’ve got round it for now by using limit="999". Pagination would probably be a better solution, but with only about 15 live articles, it’s not enough of a problem to motivate me enough to look into it yet. (I’ve set the limit for the homepage at 1 using the preferences, but I want them all on the archive page.)

Thanks!

Offline

#2 2008-04-18 18:29:59

bancroft
Member
Registered: 2005-09-30
Posts: 39

Re: Search result(s)

<txp:if_search_results> & <txp:newer> <txp:older> for the pagination

Last edited by bancroft (2008-04-18 19:25:58)

Offline

#3 2008-04-18 20:28:01

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Search result(s)

My question is: is there any way to be able to automatically recognise if there’s 1 result, and thus display “result”, or more, and thus display “results”?

Little PHP line could do it:

<txp:php> 
	if(search_result_count(array('text' => '')) == '1') echo 'result';
	else echo 'results';
</txp:php>

Last edited by Gocom (2008-04-18 20:29:17)

Offline

#4 2008-04-18 21:32:53

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

Re: Search result(s)

If you leave out the text attribute from <tpx:search_result_count />, the default text display is ‘articles found’ when there are 0 or more than 1 search results, and ‘article found’ when there is 1 result. Or whatever it says in your own localization, because this is in the txp_lang table in the database. So if you prefer ‘result’ over ‘article’, change it in the txp_lang table (look for the strings article_found and articles_found).

Offline

Board footer

Powered by FluxBB