View Single Post
  #4  
Old 11-03-2005, 01:38 PM
StevieG StevieG is offline
Senior Member
 
Join Date: Jan 2003
Location: Baltimore, MD, USA
Posts: 157
Default Re: Help me create a 2+2 Firefox Search Engine

[ QUOTE ]
Using the directions here I'm trying to create a plugin for Firefox to add a 2+2 search to the drop down search menu.

I have a problem with one line of the code, the "input name".

The problem is, there is no ampersand (&amp in the address when I perform a 2+2 search. Anyone know of a way around this?

Other than that, it works fine. I got it to show up in the menu with the lightbulb icon but whenever you search for something it just takes you to the search page

[/ QUOTE ]

Always cool to try this stuff out, so I thought I would do some more.

There are two basic reasons you are not getting search results: (1) you need to point to the search results page dosearch.php not the form page, search.php, and (2) you need to get the right input variables, especially for the user field.

So I took the liberty of doing that. The search plugin follows, with comments in blue:

<font class="small">Code:</font><hr /><pre>
<font color="blue"># 2+2 Forum Search Plugin for Firefox by KneeCo and StevieG</font>
<font color="blue"># comments start with the # sign</font>

<font color="blue"># The search tag specifies a name and description for our</font>
<font color="blue"># search plugin, and where to go on the Web to peform the</font>
<font color="blue"># actual search. We can find the input parameters for the </font>
<font color="blue"># search at http://forumserver.twoplustwo.com/search.php</font>
<font color="blue"># but the actual page that accepts those inputs and does</font>
<font color="blue"># the work is http://forumserver.twoplustwo.com/dosearch.php</font>
<font color="blue"># so we make that the action in the search tag.</font>
&lt;search
version="1.0"
name="2+2 Forum Search"
description="A Search Plugin for 2+2 Forums"
action="http://forumserver.twoplustwo.com/dosearch.php"
searchForm="http://forumserver.twoplustwo.com"
method="GET"
&gt;

<font color="blue"># Inside the search tag we specify the inputs for the </font>
<font color="blue"># search. These inputs were found by analyzing the search</font>
<font color="blue"># form at http://forumserver.twoplustwo.com/search.php</font>

<font color="blue"># This is the input for the actual search terms</font>
<font color="blue"># and is the only thing the user can enter from the </font>
<font color="blue"># plugin:</font>
&lt;input name=" Words" user=""&gt;

<font color="blue"># This input specifies which forum to search. </font>
<font color="blue"># Since the user can only input one thing (the search </font>
<font color="blue"># words) we will use a default of All Forums.</font>
&lt;input name="Forum[]" value="All_Forums"&gt;

<font color="blue"># This section includes the date range information</font>
<font color="blue"># the value listed here is to search for anything newer than</font>
<font color="blue"># 1 week. This can be changed by changing the value or</font>
<font color="blue"># type. Type can be d,w,m, or y for day, week, month, or year,</font>
<font color="blue"># respectively.</font>
&lt;input name="daterange" value="1"&gt;
&lt;input name="newerval" value="1"&gt;
&lt;input name="newertype" value="w"&gt;
<font color="blue"># If you want to stipulate a search for things older than</font>
<font color="blue"># a certain time, then uncomment and use the inputs below</font>
<font color="blue"># &lt;input name="olderval" value="3"&gt;</font>
<font color="blue"># &lt;input name="oldertype" value="d"&gt;</font>

<font color="blue"># Other inputs </font>
&lt;input name="fromsearch" value="1"&gt;
&lt;input name="checkwords" value="1"&gt;
&lt;input name="where" value="sub"&gt;

&lt;/search&gt;
</pre><hr />

You can save all that in your Program Files\Mozilla Firefox\searchplugins directory as twoplustwo.src to use it. Be sure to save as plain text, no markup for color. I would also grab this image and save it as twoplustwo.png to get an icon in the search pull down.

As people have pointed out, though, the 2+2 Forum search does suck, and many people use Google instead. So let's make a Google search for 2+2 specifically. To do this, I modified the existing google.src:

<font class="small">Code:</font><hr /><pre>
<font color="blue"># Mozilla/Google plug-in by amitp+mozilla@google.com</font>
<font color="blue"># Modified by StevieG for search by site</font>

&lt;search
name="2+2 through Google"
description="Google Search of Two Plus Two Forums"
method="GET"
action="http://www.google.com/search"
queryEncoding="utf-8"
queryCharset="utf-8"
&gt;

&lt;input name="q" user&gt;
&lt;inputnext name="start" factor="10"&gt;
&lt;inputprev name="start" factor="10"&gt;
&lt;input name="ie" value="utf-8"&gt;
&lt;input name="oe" value="utf-8"&gt;

<font color="blue"># this extra input does search by site</font>
<font color="red">&lt;input name="as_sitesearch" value="forumserver.twoplustwo.com"&gt;</font>

&lt;interpret
browserResultType="result"
charset = "UTF-8"
resultListStart="&lt;!--a--&gt;"
resultListEnd="&lt;!--z--&gt;"
resultItemStart="&lt;!--m--&gt;"
resultItemEnd="&lt;!--n--&gt;"
&gt;
&lt;/search&gt;
</pre><hr />

Save this as google2p2.src in the Mozilla Firefox/searchplugins directory and save this image as google2p2.gif for a nice icon.
Reply With Quote