It would be great if a open search description could be included into the search module. By that users could add there favorite websites search directly to the browser.

Help on how to create such a search description can be found here.

Comments

bloomaniac’s picture

Nearly half a year after my last post I want to refresh this topic.
Firstly I noticed that I've forgotten to insert the link to the initial post. Sorry about that. The right one is here.

This functionality have already implemented in the OpenSearch Client Module but I think it would be a useful feature in the core.

I'm only knowing some PHP basics and it's the same with Drupal. But I started to write some code that implements the search search description. There are several things to be done.

Firstly we have to show the browser where it can find the search description. This is done by a message in the page header which looks like this:
<link rel="search" type="application/opensearchdescription+xml" title="searchTitle" href="pluginURL">
I don't know on how to add this message to every drupal page that is shown.

After that we have to create a page that shows some xml. I've written the following code therefore. But I don't know how to say the menu- module that this xml-file should be accessible under a speacial url.

function search_description_page() {
	
	//say Drupal that will be a xml-only page
	
	print('<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">');
	print('<ShortName>'.variable_get(searchdesc_title).'</ShortName>');
	print('<Description>'.variable_get(searchdesc_description).'</Description>');
	print('<InputEncoding>UTF8</InputEncoding>');//I don't know if this is right for Drupal
	print('<Image width="16" height="16">PATH_TO_FAVICON</Image>');//How do I get the path to the currently used favicon?
	print('<Url type="text/html" method="GET" template="PATH_TO_DRUPAL_SITE/search/node/{searchTerms}"/>');
	print('</OpenSearchDescription>');
}

The last is to extend the search modules settings page. I've created that with this code which can simple inserted into the search_admin_settings() function:

// Search description:
  $form['search_description_settings'] = array('#type' => 'fieldset', '#title' => t('Search description'));
  $form['search_description_settings']['searchdesc_enabled'] = array('#type' => 'checkbox', '#title' => t('Enable search description'), '#default_value' => variable_get('searchdesc_enable', TRUE), '#description' => t('Enable the search description. This makes it possible for the browser to find your search.'));
  $form['search_description_settings']['searchdesc_title'] = array('#type' => 'textfield', '#title' => t('Name of the search'), '#default_value' => variable_get('searchdesc_title', 'My Search'), '#size' => 20, '#maxlength' => 20, '#description' => t('The title of the search engine. Later shown in the browser.'));
  $form['search_description_settings']['searchdesc_description'] = array('#type' => 'textfield', '#title' => t('Description of the search'), '#default_value' => variable_get('searchdesc_description', 'Drupal site search.'), '#size' => 100, '#maxlength' => 100, '#description' => t('A short description of your search.'));
    

I hope you'll have a look over this and help me with the problems I have.

chx’s picture

Status: Active » Closed (won't fix)

write your own contrib search module, that happened with opensearch and fastsearch already. if you want to the search page can be altered by form_alter.