Monday, September 21, 2009

Create your own search control

I was looking for a way to get rid of the icon gosearch.gif in the Search Area in SharePoint:
There is no way to replace the image with a css class, the only thing you can do is hide it with a new class that is called td.sbgo img and add the display:none to it.

So you must create a new feature, which is really easy.

Copy the OSearchBasicFeature folder in the Feature directory in the 12 hive.

Rename to whatever you like, LisesSearch is fine =)

Edit the feature.xml file and add a new GUID (link here)

Edit the SearchArea.xml file and add the path to your own search button (I put an image in the IMAGES folder, actually I created a new folder beneath it where I put my own search image):

Rename the Control Id in this file to something else like "LisesSearch"

Install and activate the feature

stsadm -o installfeature -filename LisesSearch\feature.xml
stsadm -o activatefeature -id "YourGUIDhere" -url http://yoursitehere/

Now, in your masterpage just edit the Control Id of the aspcontentholder "PlaceHolderSearchArea" to your own Id (in this example LisesSearch).
Now (after some branding on the sbcell and sbgo classes) the search should have your own buttons:

1 comment:

Anonymous said...

Hi Lise!

See you soon :-)

I just read a blog that explained how you easily could change the search icon with css-only, if that's the goal. Thought I should tell if anyone is interested.

Put this in your css, change the path to the icon of your choise and you are done!{
border:solid 0px #949494;
} a{
padding: 0px 0px 0px 0px !important;
margin: 0px 0px 0px 0px !important;
} a{
background-image: url(/_layouts/images/yourcustomfolder/custom_search.gif);
background-repeat: no-repeat;
background-position: top left;
} a img{
visibility: hidden;
height: 17px;
width: 17px;