tags:

views:

147

answers:

3

I want to duplicate the default search box and put it between some blocks on my left sidebar: so it would show up on every page twice ( top where it already is and on the left mid-sidebar ).

Is there an easy way to clone it and then make sure the IDs arent duplicates?

A: 

edit the module modules/search/search.module the funcion search_block. just add as much search blocks you want.: instead:

function search_block($op = 'list', $delta = 0) {
  if ($op == 'list') {
    $blocks[0]['info'] = t('Search form');
    // Not worth caching.
    $blocks[0]['cache'] = BLOCK_NO_CACHE;
    return $blocks;
  }
  else if ($op == 'view' && user_access('search content')) {
    $block['content'] = drupal_get_form('search_block_form');
    $block['subject'] = t('Search');
    return $block;
  }
}

i think this would work:

function search_block($op = 'list', $delta = 0) {
  if ($op == 'list') {
    $blocks[0]['info'] = t('Search form');
    // Not worth caching.
    $blocks[0]['cache'] = BLOCK_NO_CACHE;
    $blocks[1]['info'] = t('Search form');
    $blocks[1]['cache'] = BLOCK_NO_CACHE;
    return $blocks;
  }
  else if ($op == 'view' && user_access('search content')) {
    $block['content'] = drupal_get_form('search_block_form');
    $block['subject'] = t('Search');
    return $block;
  }
}
useless
Never edit modules, use hooks, theming etc... If no way to fix, upload to drupal.org patches - it is recommended, but not in current question.
Nikit
+4  A: 

Add block with php filter:

print drupal_get_form('search_block_form');


or print it in page.tpl.php, example from Zen theme:

<?php if ($search_box): ?>
  <div id="search-box">
  <?php print $search_box; ?>
  </div> <!-- /#search-box -->
<?php endif; ?>
Nikit
How would I implement this though if I already have existing blocks generated by `echo $left;`? As previously stated I want it between blocks. As far as I know I can't embed server-side within blocks.
meder
Create (add) new block! and insert code...
Nikit
Well, it doesnt seem to be generating it because it probably isnt defined at that point in time.
meder
Did you enable Search module?
Nikit
I did. This won't generate it, you have to create a custom module.
meder
In usual way it's work.
Nikit
A: 

I had to use another module for this and enable it.

meder