Author Topic: RAWR - Advanced Search, for use on any template.  (Read 3611 times)

0 Members and 1 Guest are viewing this topic.

Offline TSG

  • Moderator
  • Tireless poster
  • *****
  • Posts: 1934
    • View Profile
    • RAWR-Designs
RAWR - Advanced Search, for use on any template.
« on: November 21, 2007, 03:28:59 PM »
If you are after an advanced search for your template, try this :) 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: [Select]
<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: [Select]
<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 :D

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 22, 2007, 04:10:49 AM by That_Stevens_Guy »

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: RAWR - Advanced Search, for use on any template.
« Reply #1 on: November 21, 2007, 03:32:30 PM »
you say "more than 3", but it is actually "3 or more"

Offline TSG

  • Moderator
  • Tireless poster
  • *****
  • Posts: 1934
    • View Profile
    • RAWR-Designs
Re: RAWR - Advanced Search, for use on any template.
« Reply #2 on: November 21, 2007, 03:34:07 PM »
you say "more than 3", but it is actually "3 or more"

My bad, made it half asleep :D, i will fix it.

Offline KalleB

  • Occasional poster
  • *
  • Posts: 97
    • View Profile
Re: RAWR - Advanced Search, for use on any template.
« Reply #3 on: November 21, 2007, 03:44:48 PM »
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...

Offline TSG

  • Moderator
  • Tireless poster
  • *****
  • Posts: 1934
    • View Profile
    • RAWR-Designs
Re: RAWR - Advanced Search, for use on any template.
« Reply #4 on: November 21, 2007, 03:52:10 PM »
Probably, but i'm giving a generic code for all to use, feel free to create :)

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, 04:36:17 PM by That_Stevens_Guy »

Offline forthehandyman

  • Occasional poster
  • *
  • Posts: 27
    • View Profile
Re: RAWR - Advanced Search, for use on any template.
« Reply #5 on: November 21, 2007, 06:03:36 PM »
Code: [Select]
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: [Select]
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: [Select]
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

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: RAWR - Advanced Search, for use on any template.
« Reply #6 on: November 21, 2007, 06: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: [Select]
searchFrom ="http://%host%%folder%"
please TSG, apply this kind of correction to any use of %symbols%, and correct the posted version

Offline TSG

  • Moderator
  • Tireless poster
  • *****
  • Posts: 1934
    • View Profile
    • RAWR-Designs
Re: RAWR - Advanced Search, for use on any template.
« Reply #7 on: November 22, 2007, 04:10:04 AM »
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 :P
« Last Edit: November 22, 2007, 04:12:39 AM by That_Stevens_Guy »