You are here

function template_preprocess_search_by_page_form in Search by Page 6

Same name and namespace in other branches
  1. 8 search_by_page.module \template_preprocess_search_by_page_form()
  2. 7 search_by_page.module \template_preprocess_search_by_page_form()

Processes variables for search-by-page-form.tpl.php.

The $variables array contains the following arguments:

  • $form

See also

search-by-page-form.tpl.php

File

./search_by_page.module, line 1276
Main module file for Drupal module Search by Page.

Code

function template_preprocess_search_by_page_form(&$variables) {
  $variables['search'] = array();
  $hidden = array();
  $variables['environment'] = $variables['form']['environment']['#value'];
  $variables['is_block'] = $variables['form']['is_block']['#value'];

  // Provide variables named after form keys so themers can print each
  // element independently.
  foreach (element_children($variables['form']) as $key) {
    $type = $variables['form'][$key]['#type'];
    if ($type == 'hidden' || $type == 'token') {
      $hidden[] = drupal_render($variables['form'][$key]);
    }
    else {

      // See if this renders to something (e.g. not a 'value' type).
      $markup = drupal_render($variables['form'][$key]);
      if ($markup) {
        $variables['search'][$key] = $markup;
      }
    }
  }

  // Hidden form elements have no value to themers. No need for separation.
  $variables['search']['hidden'] = implode($hidden);

  // Collect all form elements to make it easier to print the whole form.
  $variables['search_form'] = implode($variables['search']);
}