I want to add a search box in my Primary links header. Not just a link to the search page, but an actual search box where people type in what they're looking for and click "Submit." I'm sure this is possible but I don't know how.

Comments

bwv’s picture

There are several themes that will allow you to place a search box in the same vicinity as the primary links (I am thinking of the bluemarine theme, for one). Go to theme, global settings, and look for the search box form.
----------------------------------------------------------------------
http://www.bwv810.com/

I am a writer and researcher. In my spare time I build websites with Drupal.
Je peux communiquer en français. / Я могу общаться на русском языке.

vj0914’s picture

I ran into same problem before, all you need to do is to copy code below, and past inside your primary links section, you might have to do some CSS change to make it look right.

print $search_box

below is how it looks like inside the primary

if (isset($primary_links)) {

print theme('links', $primary_links)

}
print $search_box

you might see submit button, you might not, if you don't, you need to go to template.tpl.php add following code to it

/**
* Altering search form
*/

function phptemplate_search_theme_form($form) {
$form['#prefix']='

';
//unset ($form['submit']);

$form['submit'];
$form['search_theme_form']['#title'] = t('Search');

return drupal_render($form);
}
?>

hopefully this helps your case.

JonMB’s picture

Thank you both for the quick replies. I will try these solutions.

Update: I still seem to be having a problem. All I see on the Primary links menu is a link saying "Edit primary links."

Here is my code:

<div id="nav">
<?php if (isset($primary_links)) { ?><?php print theme('links', $primary_links, array('class' =>'links', 'id' => 'navlist')) ?> <?php print $search_box ?> <?php } ?>
</div>
vj0914’s picture

you should go to your page.tpl.php file, and find where your primary_links section is, then paste the print search box code there.

JonMB’s picture

I got it working now, and I can position it with CSS. Thanks everyone.

Danilon’s picture

what do you do to add search box in primary links ???

mtpultz’s picture

I want to add the search box to the primary links as well but the designer wants it between primary links. So you would have
and I can't convince them otherwise. How would you accomplish this?

candelas’s picture

the print $search_box didnt work for me in a block with a menu, so i did

<?php
$buscar=module_invoke('search', 'block', 'view', 0); 
print $buscar[content];
?>

//trying to answer one question for each one that i make.
//this way, drupal will be more friendly and strong

lecinema44’s picture

Any idea how to remedy this?

candelas’s picture

i use it in a block that anonymous users can see and i have not that problem.

//trying to answer one question for each one that i make.
//this way, drupal will be more friendly and strong

lecinema44’s picture

I have it printed in the top bar, and used css to move it down beside primary links. It is perfect, except for the fact anon users cant see it. No idea what to do!