0
votes

I'm attempting to put a search block into my Drupal 7 theme. I have included the following into the theme:

<?php
        $block = block_load('dkan_sitewide', 'dkan_sitewide_search_bar');
        if($block):
            $search = _block_get_renderable_array(_block_render_blocks(array($block)));
            print render($search);
        endif;
    ?>

The above code was taken from the Nuboot Radix theme.

This is what I see:

enter image description here

How do change the search bar? I want to:

  • Remove the label
  • Move the submit button onto the same line as the search bar
  • Stop the bar going full width
  • Change the button text
  • Change the text inside the search bar
1

1 Answers

1
votes

There is a function in /profiles/dkan/modules/dkan/dkan_sitewide/dkan_sitewide.blocks.inc called dkan_sitewide_dataset_search_form:

function dkan_sitewide_dataset_search_form($form, $form_state) {
    $form['search'] = array(
      '#type' => 'textfield',
      '#attributes' => array(
          'placeholder' => t('Search'),
      ),
      '#size' => 50,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Search'),
    );
    return $form;
}

Editing the values in this array gives you some (very limited) control over the styling of the global search bar.

Keep in mind that editing this file directly is a bad idea, since it will be overwritten with the default contents every time you update DKAN. Unfortunately I am unable to find any other workout at the moment.