Go Back   vb.org Archive > vBulletin Modifications > vBulletin 3.8 Modifications > vBulletin 3.8 Template Modifications
Add Google Custom Search to Navbar Drop-Down Menu Details »»
Add Google Custom Search to Navbar Drop-Down Menu
Version: 1.00, by asabet asabet is offline
Developer Last Online: Apr 2015 Show Printable Version Email this Page

Category: Miscellaneous Hacks - Version: 3.8.x Rating:
Released: 08-19-2012 Last Update: Never Installs: 3
Template Edits
Re-useable Code Code Changes Translations  
No support by the author.

This is not supported. I am not a coder. This is just something that took me a long time to figure out, and I'm hoping it will come in handy for someone else.

Warning/disclaimer: I am not responsible if this breaks your site or makes it insecure. I will not help you fix your site if you harm it while doing this mod. Make sure to have a backup of any template you modify.

My goal was to encourage people to use Google search to search my site for 3 reasons, from most to least important:
  1. It gives better results than vBulletin search (IMO)
  2. It reduces the load on our server
  3. It generates a bit of ad revenue

At the same time, I wanted registered members to have the option to use the "Advanced Search" built into vBulletin, because this really comes in handy when you want to find a specific post by a specific member, in a specific forum, etc.

The result of this mod is that when unregistered guests click on "Search" in the Navbar, they get a Google Custom Search box only. When members click on "Search", they get the Google Custom Search box as well as a link to use the regular Advanced Search (see screenshot).

It's a very easy mod to do:

1) Go to Google.com/Adsense and create a custom search engine. After you do this, you will be presented with some code, the relevant portion of which will look like this:

Code:
value="partner-pub-XXXXXXXXXXXXXXXX:XXXXXXXXXX"
Keep that part handy.

2) Go to your Navbar template and make a backup of it (copy the whole thing to a text file and save it in case you mess something up).

3) In your Navbar template, replace everything between

Code:
<!-- header quick search form -->
and

Code:
<!-- / header quick search form -->
with the following:

Code:
<div class="vbmenu_popup" id="navbar_search_menu" style="display:none;margin-top:3px" align="$stylevar[left]">
		<table cellpadding="4" cellspacing="1" border="0">
		<tr>
			<td class="alt2">
<DIV ALIGN=RIGHT>
<form action="http://www.google.com/cse" id="cse-search-box" target="_blank">
<div>
    <input type="hidden" name="cx" value="partner-pub-XXXXXXXXXXXXXXXX:XXXXXXXXXX" />
    <input type="hidden" name="ie" value="UTF-8" />
    <input type="text" name="q" size="40" />
    <input type="submit" name="sa" value="Search" />
  </div>
</form>

<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></script></DIV></td>
		</tr>

<if condition="!is_member_of($bbuserinfo, 1, 3)">
<tr>
<td class="alt2">
<DIV ALIGN=CENTER>
<font size="1">Google Custom Search (above) is the recommended </br>method for searching Mu-43.com in most cases.</br></br><a href="search.php$session[sessionurl_q]" accesskey="4" rel="nofollow">Click here to use the forum search instead</a> (useful for </br>limiting your search to specific member or subforum).</font>
</DIV></td></tr></if>

		</table>
	</div>

Make sure to make the following substitutions in the code above:
  1. Replace the "XXXXXXXXXXXXXXXX:XXXXXXXXXX" in the code above with your own Adsense code.
  2. Replace "YYYYYYYY.com" with your site's name and/or address
  3. Replace "1" and "3" after "$bbuserinfo, " with the usergroup ids for your unregistered and awaiting email confirmation groups.

That's it. See the attachment for how this will look to your members (guests only see the Google search). Feel free to try it out on my site to see how it works.

Screenshots

File Type: png 2012-08-20_0121.png (9.4 KB, 0 views)

Show Your Support

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

Comments
  #2  
Old 08-20-2012, 03:50 AM
ForceHSS ForceHSS is offline
 
Join Date: Apr 2008
Posts: 6,357
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have used this code from google long time ago and it works on vb4 as well
Reply With Quote
  #3  
Old 08-20-2012, 04:59 AM
asabet asabet is offline
 
Join Date: Dec 2008
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I was surprised that no one posted this before. Would have saved me about 5 hours of messing around .

How exactly do you get it to work in vB4, and do you have a site where I can check that out?
Reply With Quote
Reply

Thread Tools

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 01:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04295 seconds
  • Memory Usage 2,229KB
  • Queries Executed 17 (?)
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
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (2)postbit
  • (1)postbit_attachment
  • (3)postbit_onlinestatus
  • (3)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_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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete