Search using non-default section

This TXP tips covers the same ground as the previous tip on Search with Textpattern, but uses a separate section and page for the search results.

The Textpattern default method (which uses the default page to display search results) may work well for you, but in case you want to separate your search results (SEO reasons for example), follow the simple steps below.

Create your search form

<h2>Site search</h2>
<txp:search_input label="" section="search" button="Go" size="15" wraptag="p" /> 

Create your search page template

In your Presentation tab, create a new page called search.

Create a search section

In your Sections tab, create a new section called search and set all options to no. Choose search as the page to use.

Place the search results code in your search page template

<txp:article limit="10" pgonly="1" />
<h2><txp:search_result_count text="search results" /> for "<txp:page_url type="q" />"</h2>
<txp:article limit="10" />
<p><txp:older>&raquo; Next results &raquo;</txp:older></p>
<p><txp:newer>&laquo; Newest results &laquo;</txp:newer></p>

Place the search form in your page templates

Wherever you want the search form to appear in your various page tenplates, call it using <txp:output_form form="search" />.

comments powered by Disqus