Skip to content

Instantly share code, notes, and snippets.

@pmackay
Last active August 29, 2015 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmackay/3e2f102a8d3d9778e3ae to your computer and use it in GitHub Desktop.
Save pmackay/3e2f102a8d3d9778e3ae to your computer and use it in GitHub Desktop.
Setting up a search API search bar in Kalatheme
<?php if ($search_form): ?>
<?php print $search_form; ?>
<?php endif; ?>
function theme_preprocess_page(&$variables) {
$variables['search_form'] = '';
if (module_exists('search') && user_access('search content')) {
$search_box_form = drupal_get_form('search_form');
$search_box_form['basic']['keys']['#title'] = '';
$search_box_form['basic']['keys']['#attributes'] = array('placeholder' => 'Search this site');
$search_box_form['basic']['keys']['#attributes']['class'][] = 'search-query';
$search_box_form['basic']['submit']['#value'] = t('Search');
$search_box = drupal_render($search_box_form);
$variables['search_form'] = (user_access('search content')) ? $search_box : NULL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment