Skip to content

Instantly share code, notes, and snippets.

@iamEAP
Created January 16, 2014 20:07
Show Gist options
  • Select an option

  • Save iamEAP/8462456 to your computer and use it in GitHub Desktop.

Select an option

Save iamEAP/8462456 to your computer and use it in GitHub Desktop.

Revisions

  1. iamEAP created this gist Jan 16, 2014.
    20 changes: 20 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    /**
    * Page preprocess.
    */
    function phptemplate_preprocess_page(&$variables) {
    // Return the fully rendered search block, and its SimpleXMLElement equivalent.
    $block = theme('block', (object) module_invoke('google_appliance', 'block', 'view', 'google_search'));
    $block_xml = new SimpleXMLElement($block);

    // Parse out $form['#prefix'] and $form['#suffix']
    $prefix = $block_xml->xpath('//form/preceding-sibling::*[1]');
    $suffix = $block_xml->xpath('//form/following-sibling::*[1]');

    // Replace relevant XML bits in the rendered markup.
    $to_be_replaced = array($prefix[0]->asXML(), $suffix[0]->asXML());
    $replacements = array('', '');
    $block = str_replace($to_be_replaced, $replacements, $block);

    // Assign the final, processed block HTML.
    $variables['search_box'] = $block;
    }