Displaying a search term in Textpattern

I’ve been doing some work with Textpattern lately, and it’s a really nice CMS for simple web sites. It’s kind of like Ruby on Rails in that 90% of the things you’d commonly do are built in, allowing you to focus on what makes your site unique.

One small thing it doesn’t have (out of the box) is a way to display the search term used on a search results page. We’re all used to the way Google displays the “Results 1 – 10 of about 2,000,000 for your search term here” near the top of the page. Even if the total number of results aren’t listed, it’s nice to know what you’ve searched for.

Fortunately, this is pretty easy to accomplish, since the built in search function puts the search term in the query string. Knowing that, the txp:page_url tag can be used to access the correct parameter:

<p>Search results for <strong><txp:page_url type="q" /></strong></p>

It’s just that simple. Happy searching!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s