Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2010-12-29 09:45:34

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

Re: customize the button search

thebombsite wrote:

<form id="searchForm" method="get" action="<txp:site_url />search">
<p><input id="searchInput" type="text" name="q" value="" size="25" /><input id="searchButton" type="submit" value="Go" /></p>
</form>

on my site, this code doesn’t point the search into the right place. do you know how i can find the right destination for the form action?
my end-goal here is to add placeholder text “search” to the input box which i will clear when the user clicks in it.

Offline

#14 2010-12-31 13:53:05

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: customize the button search

To add placeholder text you can use something like:-

<form action="<txp:site_url />search-results/" method="get">
<p><input type="text" class="navsearch" size="15" name="q" onblur="if(this.value=='') this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue) this.value='';" value="Search..." /> <input type="submit" value="search" class="search_button" title="Submit Search" /></p>
</form>

As for where to point the search, that is entirely up to you. By default the standard Txp tags send the search results to the front-page, which, in the above code, would require changing action="<txp:site_url />search-results/" to action="<txp:site_url />". The only problem with this is that it can end up requiring a complex looking page template for the frontpage which includes <txp:if_category> and <txp:if_search> tags. Personally I just find it easier to allocate a specific section for the search results and adding it to the “action” attribute but that is a decision for you to make.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

Board footer

Powered by FluxBB