The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Radio Buttons for search
I currently have a custom google search bar on my site which only searches sites that I have allowed in google when creating the search. The search results are also displayed within a page which looks like my website. This all works fantastically well but I would like to add to improve the search.
I want to add two radio buttons, one for WWW and one for my site, so when the radio button WWW is selected it does as abve searches the sites I have allowed in google and displays them within its page as it currently does. When my sites radio button is selected it just does a quick search of MY SITE only and displays the results in a page looking like my site. I have tried before to do this but haven't been able to master it, I would really appreciate any help as I really realy want this. Here is my crrent search code in the navbar template - Code:
<div id="globalsearch" class="globalsearch"> <form action="http://www.midwiferyonline.co.uk/googlesearch.php" id="cse-search-box"> <div> <input type="hidden" name="cx" value="partner-pub-XXXXXXXXXXXXXXXXXXXXXXXX" /> <input type="hidden" name="cof" value="FORID:10" /> <input type="hidden" name="ie" value="UTF-8" /> <span class="textboxcontainer"><span> <input type="text" name="q" size="20" /></span></span> <span class="buttoncontainer"><span><input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search<vb:if condition="$stylevar['textdirection'] == 'rtl'">_rtl</vb:if>.<vb:if condition="(is_browser('ie') AND !is_browser('ie', 7) AND !is_browser('ie', 8))">gif<vb:else />png</vb:if>" name="submit" onclick="document.getElementById('navbar_search').submit;" tabindex="100"/></span></span> </div> </form> PHP Code:
|
#2
|
|||
|
|||
Anyone able to help me please as I'm stumped!
|
#3
|
|||
|
|||
You might be able to do that with javascript. Add an onsubmit function to the form tag, and if the radio button is selected for your site, change the action of the form to search.php?do=process. You also need the search term to be in a variable called "query", so you could add a new hidden field named query and set it to the value of the q input field if you're going the site search page.
|
#4
|
|||
|
|||
Thank you for replying but that just went straight over my head lol. I've never wrote JavaScript before and as for the rest of it I have no idea. I thought it would be something easy that I was just too thick to see.
|
#5
|
|||
|
|||
There may be some other way to do it - you can probably redirect to the search page from the php script. But to be honest I can't quite figure out how that script works because it seems that it doesn't do anything except display a template.
|
#6
|
|||
|
|||
Lol oops that's because it does..
Here's the template - Code:
{vb:stylevar htmldoctype} <html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html"> <head> <title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title> {vb:raw headinclude} {vb:raw headinclude_bottom} </head> <body> {vb:raw header} {vb:raw navbar} <div id="pagetitle"> <h1>{vb:raw pagetitle}</h1> </div> <h2 class="blockhead">Your are searching using Google!</h2> <div class="blockbody"> <div class="blockrow"> <div id="cse-search-results"></div> <script type="text/javascript"> var googleSearchIframeName = "cse-search-results"; var googleSearchFormName = "cse-search-box"; var googleSearchFrameWidth = 800; var googleSearchDomain = "www.google.co.uk"; var googleSearchPath = "/cse"; </script> <script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script> </div> </div> {vb:raw footer} </body> </html> When something is searched for The php page renders the template to display the results from google into (my google search template, the code in this post). It's so the results look a part of my site. Does that make sense? |
#7
|
|||
|
|||
You could try putting something like this near the beginning of your php script (maybe just under require_once('./global.php')):
PHP Code:
the 'if' condition needs to be changed, I couldn't figure it out because you provided a picture of the radio buttons but not the code (or maybe you only made a picture?) ETA: the $_REQUEST['q'] probably needs to be encoded for a url - I'll have to look that up. |
#8
|
|||
|
|||
Thanks, Yeah I only made a picture lol, I haven't done the code for the radio buttons as I don't now how to incorporate that into what I've already got.
I find it a lot harder editing/adding to something that already exists than writing something of my own from scratch. |
#9
|
|||
|
|||
Well, I only know the basics of formatting using html, but I think basically it would be like:
Code:
<div id="globalsearch" class="globalsearch"> <form action="http://www.midwiferyonline.co.uk/googlesearch.php" id="cse-search-box"> <div> <input type="hidden" name="cx" value="partner-pub-XXXXXXXXXXXXXXXXXXXXXXXX" /> <input type="hidden" name="cof" value="FORID:10" /> <input type="hidden" name="ie" value="UTF-8" /> <span class="textboxcontainer"><span> <input type="text" name="q" size="20" /></span></span> Midwifery Online <input type="radio" name="source" value="0"> WWW <input type="radio" name="source" value="1"> <span class="buttoncontainer"><span><input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search<vb:if condition="$stylevar['textdirection'] == 'rtl'">_rtl</vb:if>.<vb:if condition="(is_browser('ie') AND !is_browser('ie', 7) AND !is_browser('ie', 8))">gif<vb:else />png</vb:if>" name="submit" onclick="document.getElementById('navbar_search').submit;" tabindex="100"/></span></span> </div> </form> I added the line in red. The maybe the code could be: PHP Code:
|
#10
|
|||
|
|||
Kh99, I tried it but both radio buttons still show results from the google search i.e the web. Just selecting my site doesn't use the sites search.
Any other ideas? --------------- Added [DATE]1330284715[/DATE] at [TIME]1330284715[/TIME] --------------- Sorry ignore that, I edited the wrong file. If I tick my site for search and then search, it just gives me a blank page with this as the URL - Code:
http://www.midwiferyonline.co.uk/googlesearch.php?cx=partner-pub-XXXXXXXXXXXXXXXX&cof=FORID%3A10&ie=UTF-8&q=study+day&source=0&submit.x=16&submit.y=18&siteurl=www.midwiferyonline.co.uk%2Fsearch.php%3Fsearchid%3D115155&ref=www.midwiferyonline.co.uk%252Fsearch.php%253Fsearchid%253D115154 Code:
http://www.midwiferyonline.co.uk/googlesearch.php?cx=partner-pub-XXXXXXXXXXXXXXXXXXXXXXXXXXX&cof=FORID%3A10&ie=UTF-8&q=study+day&source=1&submit.x=1&submit.y=9&siteurl=www.midwiferyonline.co.uk%2Fsearch.php%3Fsearchid%3D115155&ref=www.midwiferyonline.co.uk%252Fsearch.php%253Fsearchid%253D115154 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|