rejetto forum
May 24, 2012, 11:24:47 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: This forum is free, you do NOT need to register to post. But you may.
PROBLEMS? QUESTIONS? CLICK HERE!
Fill the survey!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: RAWR - Advanced Search, for use on any template.  (Read 2323 times)
0 Members and 1 Guest are viewing this topic.
TSG
Moderator
Insane poster
*****
Offline Offline

Australia Australia

Posts: 1919



View Profile WWW
« on: November 21, 2007, 09:28:59 AM »

If you are after an advanced search for your template, try this Smiley this is the advanced form featured in the ToG, it can be easily modified to work with any template.

Place this in the head of your template, between <head/> markup:
Code:
<script type="text/javascript">
/*
 RAWR - Advanced Search - v0.4
 (c) 2007, RAWR Designs, Some Rights Reserved -
Christopher "That Stevens Guy" Stevens
Richard "Giant Eagle" Tuininga
 (CC) http://creativecommons.org/licenses/by-nc-sa/3.0/

 Any queries? -
Email: that.stevens.guy@gmail.com, r.tuininga@quicknet.nl
Forum: http://www.rejetto.com/forum/index.php?board=34.0
  Homepage: http://www.rawr-designs.com/
*/

function searchQuery() {
frm = document.searchForm;
if(frm.query.value.length < 3) {
alert("Please enter a search with 3 or more characters. Thankyou.");
} else {
frm.recursive.checked ? recursive ="&recursive" : recursive ="";
for(x=0; x<frm.choice.length; x++) {
if(frm.choice[x].checked ==1) {
if(frm.choice[x].value =="file") {
searchMode ="?files-filter=";
filter="&folders-filter=%5C";
} else if(frm.choice[x].value =="folder") {
searchMode ="?folders-filter=";
filter="&files-filter=%5C";
} else {
searchMode ="?filter=";
filter="";
}
}
}
for(c=0; c<frm.root.length; c++) {
if(frm.root[c].checked ==1) {
frm.root[c].value =="current" ? searchFrom ="http://%host%%folder%": searchFrom = "http://%host%";
}
}
document.location.href = searchFrom+searchMode+"*"+frm.query.value+"*"+recursive+filter;
}
}
</script>
<noscript><style type="text/css">.hide{display:none}</style></noscript>

Place this in the template somewhere, between <body/> markup:
Code:
<noscript>
<form action="/" method=GET>
<input type=input name=search size=30 maxlength=32/>
<input type=submit value="Search"/>
</form>
<i>Enable JavaScript for more options...</i>
</noscript>
<form class=hide name=searchForm method=GET action="javascript:searchQuery()">
<input type=input name=query size=30 maxlength=32/>
<input type=submit name=searchBtn value="Search"/><br>
<input type=radio name=choice value="file"/> File(s)
<input type=radio name=choice value="folder"/> Folder(s)
<input type=radio name=choice value="both" checked=1/> Both
<input type=checkbox name=recursive checked=1/> Recursive<br>
<input type=radio name=root value="root" checked=1/> From Root Directory
<input type=radio name=root value="current"/> From Current Directory
</form>

Hopefully this is helpful to people Cheesy

Note: Users that have javascript disabled should be shown a simple search form that uses the "?search=" feature. You can find this in the html part between the <noscript/> markup.
« Last Edit: November 21, 2007, 10:10:49 PM by That_Stevens_Guy » Logged

rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #1 on: November 21, 2007, 09:32:30 AM »

you say "more than 3", but it is actually "3 or more"
Logged
TSG
Moderator
Insane poster
*****
Offline Offline

Australia Australia

Posts: 1919



View Profile WWW
« Reply #2 on: November 21, 2007, 09:34:07 AM »

you say "more than 3", but it is actually "3 or more"

My bad, made it half asleep Cheesy, i will fix it.
Logged

KalleB
Experienced poster
***
Offline Offline

Finland Finland

Posts: 97



View Profile
« Reply #3 on: November 21, 2007, 09:44:48 AM »

I don't know too much HTML+CSS but would it be possible to put these "Recursive", "File(s)", "From Current Directory" (and so on) into a similar menu that the current HFS default template has? Then these selections would not be visible all the time but only when mouse is over the search field...
Logged
TSG
Moderator
Insane poster
*****
Offline Offline

Australia Australia

Posts: 1919



View Profile WWW
« Reply #4 on: November 21, 2007, 09:52:10 AM »

Probably, but i'm giving a generic code for all to use, feel free to create Smiley

If someone can help you... it is easy enough to implement, just have a play with the menu rejetto has implemented.
« Last Edit: November 21, 2007, 10:36:17 AM by That_Stevens_Guy » Logged

forthehandyman
Regular poster
**
Offline Offline

United States United States

Posts: 27


View Profile
« Reply #5 on: November 21, 2007, 12:03:36 PM »

Code:
frm.root[c].value =="current" ? searchFrom ="http://"+%host%+%folder%: searchFrom = "http://"+%host%;

I had to change the above code slightly to get the Search to work in HFS Live Local 2.  Without the following change, when you clicked on the Search button, nothing happened.

New code is:

Code:
frm.root[c].value =="current" ? searchFrom ="http://"+'%host%'+'%folder%': searchFrom = "http://"+'%host%';

And, to take it one step further, I use both http: and https: to connect.  To get the Search feature to work with both http: and https: connections I changed the code again to read as follows:

Code:
frm.root[c].value =="current" ? searchFrom ="//"+'%host%'+'%folder%': searchFrom = "//"+'%host%';

That way the search feature automatically uses either http: or https:, dependent upon which connection method you are using.  I don't know if this is correct coding or not, but it has always worked for me and doesn't seem to have any adverse effects.

JEFF
Logged
rejetto forum
« Reply #5 on: November 21, 2007, 12:03:36 PM »

Do you like this software? Consider even $2
 Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #6 on: November 21, 2007, 12:20:31 PM »

I had to change the above code slightly to get the Search to work in HFS Live Local 2.  Without the following change, when you clicked on the Search button, nothing happened.

that is actually a bug
i suggest fixint it this way
Code:
searchFrom ="http://%host%%folder%"

please TSG, apply this kind of correction to any use of %symbols%, and correct the posted version
Logged
TSG
Moderator
Insane poster
*****
Offline Offline

Australia Australia

Posts: 1919



View Profile WWW
« Reply #7 on: November 21, 2007, 10:10:04 PM »

Sorry guys, this was converted from an external javascript file, i have to send the hfs symbols as string vars to the js then build a string, forgot about this, should be fine now. I didn't test the code i just put it here and hoped for the best. Was 3am Tongue
« Last Edit: November 21, 2007, 10:12:39 PM by That_Stevens_Guy » Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!


Google visited last this page May 07, 2012, 10:22:29 PM