I have several Apache Solr search configurations, filtered to different Content Types to be used on a variety of view pages. These "pages" provide their own search form, but I need to be able to embed these search fields as blocks, so they can be implemented in page layouts within Context.

So, create a block and load the form with drupal_get_form:

 * Implements hook_block_info()
 * @return [type] [description]
function example_block_info() {
  $block['mwb_video_block'] = array(
    'info' => t('Example Search Block'),
    'cache' => DRUPAL_CACHE_PER_ROLE,

  return $block;

 * Implements hook_block_view()
function example_block_view($delta = '') {
  $block = array();

  switch ($delta) {
    case "example_search_block":
      $block['subject'] = "";
      $block['content'] = example_render_search_block();

  return $block;

function example_render_search_block() {
  $form = drupal_get_form("search_form");
  return drupal_render($form);

Simple, right? Well, I tried that with varying results, none returning a form. A DPM of the loaded form object loads in the form, but nothing renders in the return output. Is there a process that i'm missing out on here that only seems to be tied to the Apache Solr search form?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.