Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Template Modifications
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Replace search with Google Custom Search Details »»
Replace search with Google Custom Search
Version: 1.00, by Dave-ahfb Dave-ahfb is offline
Developer Last Online: Dec 2018 Show Printable Version Email this Page

Category: Integration with vBulletin - Version: 4.0.0 Beta 4 Rating:
Released: 11-30-2009 Last Update: Never Installs: 152
Template Edits
Re-useable Code  
No support by the author.

This mod assumes you have an adsense account and are using Google Custom Search.

You want to make sure your results page is named something other than the vb default search.php, this leaves the vb option open to those who click "advanced search"

Open your template navbar


find
PHP Code:
<form action="search.php?do=process" method="post" id="navbar_search"

replace with the form line of the google supplied code
example:
PHP Code:
<form action="http://www.ahfb2000.com/google.php" id="cse-search-box"


find
PHP Code:
<input type="hidden" name="s" value="{vb:raw session.sessionurl}" />
<
input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
<
input type="hidden" name="do" value="process" /> 

replace with the first 3 hidden input types in your google code
example:
PHP Code:
    <input type="hidden" name="cx" value="partner-pub-xxxxxxxxxxxxxxxxxxxxxxx" />
    <
input type="hidden" name="cof" value="FORID:10" />
    <
input type="hidden" name="ie" value="ISO-8859-1" /> 


find
PHP Code:
<input type="text" value="" name="query" class="textbox" /> 

replace with
PHP Code:
<input type="text" value="" name="q" class="textbox" /> 


find
PHP Code:
<input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search.png" name="submit" onclick="document.getElementById('navbar_search').submit;" /> 

replace with
PHP Code:
<input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search.png" name="sa" onclick="document.getElementById('navbar_search').submit;" /> 


find
PHP Code:
</form

add this after
PHP Code:
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script

Screenshots

File Type: jpg Image1.jpg (107.9 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #172  
Old 04-28-2012, 12:26 PM
sportsoutlaw sportsoutlaw is offline
 
Join Date: Nov 2004
Location: Texas
Posts: 159
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

just installed on 4.1.11 and works well.
Reply With Quote
  #173  
Old 07-09-2012, 07:23 PM
lisa3876 lisa3876 is offline
 
Join Date: Apr 2007
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This still works with vB 4.2. The specific details on page 3 were really helpful. The only small change I had to make is Google Custom Search now has new code.

So on Semper's instruction on page 3 of this thread (Step 4), I had to replace the partner-pub id code with my search engine's "Search Engine Unique ID" which can be found in the Control Panel of your Google Custom Search account. Should look something like xxxxxxxxxxxxxxxxx:xxxxxxxx

Then I had to click "Make Money" in the left column of the Google Custom Search Control panel and sync my AdSense account to my Google Custom Search account.

The Search Engine Unique ID has now replaced the partnerpub ID. But the partner-pub still works if you're using it.
Reply With Quote
  #174  
Old 07-21-2012, 12:54 PM
insidegames insidegames is offline
 
Join Date: Jun 2010
Posts: 91
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It doesn't works for me -> here is my navbar code:

Code:
<div id="navbar" class="navbar">
	<ul id="navtabs" class="navtabs floatcontainer<vb:if condition="$show['member'] AND $notifications_total"> notify</vb:if>">
		{vb:raw template_hook.navtab_start}
		{vb:raw navigation}
		{vb:raw template_hook.navtab_end}
	</ul>
	<vb:if condition="$vboptions['enablesearches']">
		<div id="globalsearch" class="globalsearch">
			<form action="http://testforum.insidegames.ch/google.php" id="cse-search-box">
				<input type="hidden" name="cx" value="pub-6521811265209589" />
    <input type="hidden" name="cof" value="FORID:9" />
    <input type="hidden" name="ie" value="ISO-8859-1" />
            <span class="textboxcontainer"><span><input type="text" value="" name="q" class="textbox" /></span></span>
            <span class="buttoncontainer"><span><input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search.png" name="sa" onclick="document.getElementById('navbar_search').submit;" />  </span></span>
        </form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script>   
			<ul class="navbar_advanced_search">
				<li><a href="search.php{vb:raw session.sessionurl_q}" accesskey="4">{vb:rawphrase advanced_search}</a></li>
				{vb:raw template_hook.navbar_advanced_search}
			</ul>
		</div>
	</vb:if>
</div>
</div><!-- closing div for above_body -->

<div class="body_wrapper">
<div id="newcrumb">
 <div id="crumbL">
<div id="breadcrumb" class="breadcrumb">
	<ul class="floatcontainer">
		<li class="navbithome"><a href="index.php{vb:raw session.sessionurl_q}" accesskey="1"><img src="{vb:stylevar imgdir_misc}/navbit-home.png" alt="{vb:rawphrase home}" /></a></li>
		{vb:raw navbits.breadcrumb}
		{vb:raw navbits.lastelement}
	</ul>
	<hr />
</div>
 </div> <!-- crumb -->
 <div id="crumbR">
  <ul>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_rss'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_rss}"><img src="{vb:stylevar imgdir_misc}/icon-rss.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_twitter'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_twitter}"><img src="{vb:stylevar imgdir_misc}/icon-twitter.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_facebook'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_facebook}"><img src="{vb:stylevar imgdir_misc}/icon-facebook.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_linkedin'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_linkedin}"><img src="{vb:stylevar imgdir_misc}/icon-linkedin.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_myspace'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_myspace}"><img src="{vb:stylevar imgdir_misc}/icon-myspace.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_blogger'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_blogger}"><img src="{vb:stylevar imgdir_misc}/icon-blogger.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_youtube'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_youtube}"><img src="{vb:stylevar imgdir_misc}/icon-youtube.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_flickr'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_flickr}"><img src="{vb:stylevar imgdir_misc}/icon-flickr.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_google'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_google}"><img src="{vb:stylevar imgdir_misc}/icon-google.png" /></a></li></vb:if>
  </ul>
 </div>
 <br clear="all" />
</div> <!-- newcrumb -->

{vb:raw ad_location.ad_navbar_below}
{vb:raw ad_location.global_below_navbar}

<vb:if condition="$show['notices'] AND THIS_SCRIPT != 'register'">
	<form action="profile.php?do=dismissnotice" method="post" id="notices" class="notices">
		<input type="hidden" name="cx" value="pub-6521811265209589" />
    <input type="hidden" name="cof" value="FORID:10" /> 
    <input type="hidden" name="ie" value="ISO-8859-1" />  
		<input type="hidden" id="dismiss_notice_hidden" name="dismiss_noticeid" value="" />
		<input type="hidden" name="url" value="{vb:raw return_link}" />
		<ol>
			{vb:raw notices}
		</ol>
	</form>
</vb:if>
every search activity ends with

400. That’s an error.

Your client has issued a malformed or illegal request. That’s all we know.
Reply With Quote
  #175  
Old 10-27-2012, 11:26 PM
CountRock CountRock is offline
 
Join Date: Jun 2011
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by insidegames View Post
It doesn't works for me -> here is my navbar code:

Code:
<div id="navbar" class="navbar">
	<ul id="navtabs" class="navtabs floatcontainer<vb:if condition="$show['member'] AND $notifications_total"> notify</vb:if>">
		{vb:raw template_hook.navtab_start}
		{vb:raw navigation}
		{vb:raw template_hook.navtab_end}
	</ul>
	<vb:if condition="$vboptions['enablesearches']">
		<div id="globalsearch" class="globalsearch">
			<form action="http://testforum.insidegames.ch/google.php" id="cse-search-box">
				<input type="hidden" name="cx" value="pub-6521811265209589" />
    <input type="hidden" name="cof" value="FORID:9" />
    <input type="hidden" name="ie" value="ISO-8859-1" />
            <span class="textboxcontainer"><span><input type="text" value="" name="q" class="textbox" /></span></span>
            <span class="buttoncontainer"><span><input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search.png" name="sa" onclick="document.getElementById('navbar_search').submit;" />  </span></span>
        </form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script>   
			<ul class="navbar_advanced_search">
				<li><a href="search.php{vb:raw session.sessionurl_q}" accesskey="4">{vb:rawphrase advanced_search}</a></li>
				{vb:raw template_hook.navbar_advanced_search}
			</ul>
		</div>
	</vb:if>
</div>
</div><!-- closing div for above_body -->

<div class="body_wrapper">
<div id="newcrumb">
 <div id="crumbL">
<div id="breadcrumb" class="breadcrumb">
	<ul class="floatcontainer">
		<li class="navbithome"><a href="index.php{vb:raw session.sessionurl_q}" accesskey="1"><img src="{vb:stylevar imgdir_misc}/navbit-home.png" alt="{vb:rawphrase home}" /></a></li>
		{vb:raw navbits.breadcrumb}
		{vb:raw navbits.lastelement}
	</ul>
	<hr />
</div>
 </div> <!-- crumb -->
 <div id="crumbR">
  <ul>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_rss'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_rss}"><img src="{vb:stylevar imgdir_misc}/icon-rss.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_twitter'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_twitter}"><img src="{vb:stylevar imgdir_misc}/icon-twitter.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_facebook'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_facebook}"><img src="{vb:stylevar imgdir_misc}/icon-facebook.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_linkedin'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_linkedin}"><img src="{vb:stylevar imgdir_misc}/icon-linkedin.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_myspace'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_myspace}"><img src="{vb:stylevar imgdir_misc}/icon-myspace.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_blogger'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_blogger}"><img src="{vb:stylevar imgdir_misc}/icon-blogger.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_youtube'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_youtube}"><img src="{vb:stylevar imgdir_misc}/icon-youtube.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_flickr'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_flickr}"><img src="{vb:stylevar imgdir_misc}/icon-flickr.png" /></a></li></vb:if>
   <vb:if condition="!empty($vbulletin->options['ws_bluepearl_sp_google'])"><li><a href="{vb:raw vboptions.ws_bluepearl_sp_google}"><img src="{vb:stylevar imgdir_misc}/icon-google.png" /></a></li></vb:if>
  </ul>
 </div>
 <br clear="all" />
</div> <!-- newcrumb -->

{vb:raw ad_location.ad_navbar_below}
{vb:raw ad_location.global_below_navbar}

<vb:if condition="$show['notices'] AND THIS_SCRIPT != 'register'">
	<form action="profile.php?do=dismissnotice" method="post" id="notices" class="notices">
		<input type="hidden" name="cx" value="pub-6521811265209589" />
    <input type="hidden" name="cof" value="FORID:10" /> 
    <input type="hidden" name="ie" value="ISO-8859-1" />  
		<input type="hidden" id="dismiss_notice_hidden" name="dismiss_noticeid" value="" />
		<input type="hidden" name="url" value="{vb:raw return_link}" />
		<ol>
			{vb:raw notices}
		</ol>
	</form>
</vb:if>
every search activity ends with

400. That?s an error.

Your client has issued a malformed or illegal request. That?s all we know.
Exact same problem! HELP!
Reply With Quote
  #176  
Old 11-26-2012, 02:46 PM
g00gl3r g00gl3r is offline
 
Join Date: Sep 2005
Posts: 174
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does this show using an iframe within the site template? Or open in a new window?
Reply With Quote
  #177  
Old 01-21-2013, 06:43 PM
techbytes techbytes is offline
 
Join Date: Nov 2010
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Winter Sonata View Post
wampforum,

make sure to capitlaize the name of the temple like that ' GOOGLE'
Thank you! Thank you! Thank you!!!

After hour and a half of trying to figure out why I'm getting a blank page, Sonata saves me from pulling out my hair.

Also, thanks to OP for the mod. Very much appreciated. :up:

techbytes
Reply With Quote
  #178  
Old 03-07-2013, 09:37 AM
svensonsan svensonsan is offline
 
Join Date: Nov 2011
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is an update for this with the latest (v2) version of google custom search. I really like the google cse in vbulletin. It's much faster and with some styling in the css even the Google cse v2 will work in vbulletin 4.2

This short instruction will help if you use a two-page CSE as shown in the documentation at Multiple search boxes and results sections.

Already mentioned here:

1. Create the google.php file as mentioned on page 3 in this thread.
2. Create the GOOGLE template as mentioned on page 3 in this thread.

Now the new stuff.

1. headinclude template
copy the script-snippet at the bottom of your headinclude template.

Code:
<!-- google cse -->
<script>
  (function() {
    var cx = '00000000000000:aaaaaaaaaaa'; ///////////////CHANGE THIS TO YOUR OWN ID //// 
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = (document.location.protocol == 'https' ? 'https:' : 'http:') +
        '//www.google.com/cse/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
</script>
<!-- / google cse -->
This will "enable" the searchform and searchresults in general in your forum.


2. navbar template
Display the search form in the navigation

Search for <form action="search.php ....
comment the normal search form
Code:
<vb:comment><form action 
.... a few lines 
</form></vb:comment>
Enter the new google search form under the global search div.

Code:
<div id="globalsearch" class="globalsearch">
<gcse:searchbox-only></gcse:searchbox-only>
Now you have the search form in your forum and yes, styling will follow.

but first edit the

3. GOOGLE Template

Should look like this:

Code:
<div class="blockrow">

<gcse:search></gcse:search>

      </div>
Not the long and old version mentioned in this thread. Only the <gcse:search></gcse:search> is used to display the search results and the search bar.
If you only want to show the search results you can use <gcse:searchresults-only></gcse:searchresults-only>

4. additional.css template
The search form will look broken at first.
You should modify at least the following styles:


Code:
input.gsc-input {
font-size:11px !important;
}

#globalsearch .gsc-input-box { 
border:none !important; 
height:22px !important; 
}

#globalsearch input.gsc-search-button-v2 {
padding:4px 20px !important;
margin-top:1px !important;
}
Reply With Quote
3 благодарности(ей) от:
CAG CheechDogg, fxdigi-cash, Spika
  #179  
Old 03-07-2013, 12:08 PM
Spika's Avatar
Spika Spika is offline
 
Join Date: Jun 2006
Location: Marbella - Spain
Posts: 84
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by svensonsan View Post
There is an update for this with the latest (v2) version of google custom search. I really like the google cse in vbulletin. It's much faster and with some styling in the css even the Google cse v2 will work in vbulletin 4.2
Works Perfect!!

Thank you very much!
Reply With Quote
  #180  
Old 03-30-2013, 02:55 PM
simon661 simon661 is offline
 
Join Date: Dec 2011
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed and works for my forum, check the link to see.


http://www.railtransit-cbtc.com/CBTC...ity/forum.php?
Reply With Quote
  #181  
Old 05-07-2013, 04:00 AM
beertruck beertruck is offline
 
Join Date: Jan 2012
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

SemperFideles's instructions on the 3rd page worked for my 4.2 forum. Thanks SemperFideles!!!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:24 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08537 seconds
  • Memory Usage 2,395KB
  • Queries Executed 28 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (7)bbcode_code
  • (10)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (3)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete