free hit counters
If you are using Internet Explorer as your browser please be running at least IE 7 or above. This site does not support IE 6 or below. Go here for the latest free version including easy download and installation instructions If you want to make it real easy on yourself, download Firefox , the most popular browser in the world. It's free and simple. You'll be so glad you did.
Jan
22
2009

Move the search bar

Check out where the search box is. I moved it into the nav bar. Here’s how I did it…

First thing I did was to view the page source. From there I found the search form code and copied it. Next I went to my custom_functions.php file and created a function with it.

In your custom_functions.php file add the following code. You can put it anywhere you want but I recommend putting it at the top after the <?php tag. Remember, once you make the change, save it, and upload it to your server. Always describe the function and put it between the comment tags /*  */ at the beginning shown below in green. The comments aren’t shown on your rendered page and it just makes things easier for you to remember…

/*put the search bar in the header*/
function searchbar () {?>
<div class=”search”>
<form class=”search_form” action=”http://www.thesishacker.com/” method=”get”>
<p>
<input id=”s” class=”text_input” type=”text” onblur=”if (this.value == ”) {this.value = ‘To search, type and hit enter’;}” onfocus=”if (this.value == ‘To search, type and hit enter’) {this.value = ”;}” name=”s” value=”To search, type and hit enter”/>
<input id=”searchsubmit” type=”hidden” value=”Search”/>
</p>
</form>
</div>
<?php
}
add_action (’thesis_hook_header’,’searchbar’);

As you can see I placed the search bar in the header. In your custom.ss file add the following code. You can put it anywhere you want but I recommend putting it at the top. Remember, once you make the change, save it, and upload the new file to your server. Always describe what you’re doing by putting your descripton between the comment tags /*  */ at the beginning shown below in green. The comments aren’t shown on your rendered page and it just makes things easier for you to remember…

/*search form positioning*/
.custom .search {position: absolute;
z-index: 1;
margin: 1em 0 0 81em;
}

I tweaked it to my liking and added a z-index of 1. This makes the search form lay on top of everything else

I gave it an absolute position because I placed it in the header which has a position of relative

To see how I built the header check out this tutorial

Leaving a comment with code in it...

If you would like to leave a comment and you have examples of code you want to show, you must "escape the code". This allows the entire code to show correctly by inserting certain variable around certain tags to make them show. If you don't "escape the code" your code will show up broken, mangled, and it won't be able to be seen correctly. "Escaping the code" is very simple...

  1. Copy your code you want to show
  2. Click here to go to the site to escape the code
  3. Follow the directions, it's so easy
  4. Once you have the escaped code copied, paste it in the comments area where you want
  5. Now you can enjoy life


Go ahead, leave a comment...

{ 4 comments… read them below or add one }

Mark May 6, 2009 at 1:58 pm

As much as I try I just cannot get the search bar on top of the nav bar. I’ve tried your code and others. Any ideas?

Reply

Nasty May 7, 2009 at 12:02 pm

Do you have a link to your site so I can see what’s going on

Reply

kek May 13, 2009 at 4:27 am

unsuccessful to me. kindly assist

Reply

Nasty May 13, 2009 at 10:27 pm

You need to tell me what problems you’re having. A link to your site too..

Reply

Leave a Comment

Previous post: Add an image to your widget headline

Next post: Add a note in your post or page