The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Google Search Mod that Actually WORKS!
There is a mod on here that purports to do this, but it doesn't work.
I need a mod that places a Google Search on my site by: -Showing me where to place the Google Custom Search code that I received from Google. -Creates an entry either in the Navbar or space below the user login area. Thanks. |
#2
|
||||
|
||||
I assume you already have a Google CSE account?
|
#3
|
||||
|
||||
Take a look at my website, I have the google search working on there perfectly fine ....if that is what you are looking for I will help you out ...
https://www.cagclan.com/community/forum.php |
#4
|
||||
|
||||
Quote:
|
#5
|
|||
|
|||
Of course you do, as all Google site services.
|
#6
|
||||
|
||||
That's what I thought, but I never used it so I was not sure.
|
#7
|
||||
|
||||
Yes you do ozzy ...
|
#8
|
||||
|
||||
I wonder if Nelson has one, if he don't, it of course will not show.
|
#9
|
|||
|
|||
@nelson58, needs to spend a bit more time reading and asking more exacting questions. So far we are just messaging among ourselves.
|
#10
|
||||
|
||||
Here is what to do to get this on your site my Man ....
Step 1: Create a new template and name it "GOOGLE", make sure it's in all CAPS ! in that template add the following: Code:
<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 Site's Name Custom Search Results</h2> <div class="blockbody"> <div class="blockrow"> <div class="blockrow"> <gcse:search></gcse:search> </div> </div> </div> {vb:raw footer} </body> </html> Step 2: In your "headinclude" template add the following at the very end: Code:
<!-- google cse --> <script> (function() { var cx = 'partner-pub-0000000000000000:0000000000'; ///////////////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 --> Code:
<div id="globalsearch" class="globalsearch"> Code:
<form action="search.php?{vb:raw session.sessionurl}do=process" method="post" id="navbar_search" class="navbar_search"> <vb:comment><input type="hidden" name="s" value="{vb:raw session.sessionurl}" /></vb:comment> <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" /> <input type="hidden" name="do" value="process" /> <span class="textboxcontainer"><span><input type="text" value="" name="query" class="textbox" tabindex="99"/></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)">gif<vb:else />png</vb:if>" name="submit" onclick="document.getElementById('navbar_search').submit;" tabindex="100"/></span></span> </form> Code:
<gcse:searchbox-only></gcse:searchbox-only> <form method="get" action="http://www.yoursite.com/your-forums-path/google.php" target="_blank" class="navbar_search"> <input type="hidden" name="sitesearch" value="yoursite.com/your-forums-path/forum.php" id="pn"/> <input type="hidden" name="domains" value="yoursite.com/your-forums-path/forum.php"/> </form> Code:
<?php // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('THIS_SCRIPT', 'test'); define('CSRF_PROTECTION', true); // change this depending on your filename // ################### PRE-CACHE TEMPLATES AND DATA ###################### // get special phrase groups $phrasegroups = array(); // get special data templates from the datastore $specialtemplates = array(); // pre-cache templates used by all actions $globaltemplates = array('GOOGLE', ); // pre-cache templates used by specific actions $actiontemplates = array(); // ######################### REQUIRE BACK-END ############################ // if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line // chdir ('/path/to/your/forums'); require_once('./global.php'); // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### $navbits = construct_navbits(array('' => 'yoursite.com Site Search')); $navbar = render_navbar_template($navbits); // ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = 'yoursite.com Custom Search'; // ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### $templater = vB_Template::create('GOOGLE'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle); print_output($templater->render()); ?> --------------- Added [DATE]1410998655[/DATE] at [TIME]1410998655[/TIME] --------------- Yes he does, but hopefully this will help him get this done lol ..... |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|