Creating your own search plugin for Firefox or Flock
Creating your own firefox-flock search plugin
In this tutorial you will learn how to create your own search plugin for the browsers Firefox or Flock.
Flock:
http://flock.com
Firefox:
http://firefox.com
Now lets get started.
First you are going to want to add the code below to a new line in your .htaccess
AddType application/x-httpd-php .src
The reason for this is to tell the system that .src file (which is going to be plugin.src later on) that AddType allows you to tweak mime types without actually editing it. Google it for more information Mine Types and AddType.
Next you are going to create a new .js file. You may call it whatever you want. For now we are going to use plugin.js Next add this code into that file.
function add_plugin () {
if (typeof window.sidebar.addSearchEngine == 'function') {
window.sidebar.addSearchEngine(root + '/plugin.src', root + '/img/favicon.png', 'Website Plugin Name', 'Plugin Description');
} else {
alert('This is a Mozilla FireFox Only Feature!');
}
}
All the function does above is check to see if the browser is mozilla so Firefox or Flock and then if so sends the plugin information to your browser, and then you will get a popup notification saying 'Would you like to add this plugin..' you get the point. If not it says 'This is a Mozilla Firefox Only Feature!'. Do not forget to add the link to your favicon. Also do not forget to change [Website Plugin Name] and [Plugin Description] to your correct information.
Next you will want to add the following inside your head tags. This code includes the javascript file that we just have created into the page. The code below the JS include gets the root or in simple terms the website url. Just change http://totaldream.com/ to your website, there is an more 'correct' way to do it but it does not matter right now.
<script language="javascript" type="text/javascript" src="location/to/plugin.js"></script>
<script language="javascript" type="text/javascript">
root = 'http://totaldream.org/';
</script>
*Make sure to change the 'location/to/main.js' to the location of your file.
And last but not least, we have to fill our plugin.src code.
<search
name="totalSearchr"
description="Search the web for files!"
method="post"
action="http://totalsearchr.com/search.php"
>
<input type="hidden" name="action" value="do_search" />
<input type="text" name="query" user />
</search>
The above code is all you have to put into the plugin.src First change the name to your website, second change the description to your description.
Now for the action, this is key, you need to have a search script to be able to use the plugin. Basically what you are doing is POSTing the search query from your browser to the search.php.
*If you do not a search engine, do a quick google search for 'how to create a php search engine' or visit Pixel2Life.com and have a look around there.
Hope you learned a bit. Next tutorial will be something amazing so keep watch.
- 2121 reads