The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Replace search with Google Custom Search Details »» | |||||||||||||||||||||||||||||
Replace search with Google Custom Search
Developer Last Online: Dec 2018
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:
replace with the form line of the google supplied code example: PHP Code:
find PHP Code:
replace with the first 3 hidden input types in your google code example: PHP Code:
find PHP Code:
replace with PHP Code:
find PHP Code:
replace with PHP Code:
find PHP Code:
add this after PHP Code:
Screenshots
Show Your Support
|
Comments |
#192
|
|||
|
|||
Thanks for your support.
Finally I solved my issues with this mod: https://vborg.vbsupport.ru/showthread.php?t=297548 |
#193
|
|||
|
|||
No matter WHAT I do, the search always goes to the Google Custom Search Page rather than appearing on one of my site's pages. Users have to hit "back" to get back onto my site. Others have tried to find the cause of this unsuccessfully. I am stumped.
Here is the code that is doing this: The GOOGLE 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}</title>
{vb:raw headinclude}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<div id="pagetitle">
<h1>{vb:raw pagetitle}</h1>
</div>
<h2 class="blockhead">Google Custom Search</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.com";
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>
The headerinclude template: Code:
<meta http-equiv="Content-Type" content="text/html; charset={vb:stylevar charset}" /> <meta id="e_vb_meta_bburl" name="vb_meta_bburl" content="{vb:raw vboptions.bburl}" /> <base href="{vb:raw basepath}" /><!--[if IE]></base><![endif]--> <meta name="generator" content="vBulletin {vb:raw vboptions.templateversion}" /> <meta http-equiv="X-UA-Compatible" content="IE=9" /> <vb:if condition="$stylevar['favicon']"> <link rel="Shortcut Icon" href="{vb:stylevar favicon}" type="image/x-icon" /> </vb:if> <vb:if condition="$show['threadinfo']"> <vb:elseif condition="$show['foruminfo']" /> <meta name="keywords" content="{vb:raw foruminfo.title_clean}, {vb:raw vboptions.keywords}" /> <meta name="description" content="<vb:if condition="$pagenumber > 1">{vb:rawphrase page_x, {vb:raw pagenumber}}-</vb:if>{vb:raw foruminfo.description_clean}" /> <vb:else /> <meta name="keywords" content="{vb:raw vboptions.keywords}" /> <meta name="description" content="{vb:raw vboptions.description}" /> </vb:if> <vb:if condition="$show['fb_opengraph']"> {vb:raw facebook_opengraph} </vb:if> <vb:if condition="$show['remoteyui']"> <vb:if condition="$show['remoteyuicombo']"> <script type="text/javascript" src="{vb:stylevar yuicombopath}?{vb:stylevar yuiversion}/build/yuiloader-dom-event/yuiloader-dom-event.js&{vb:stylevar yuiversion}/build/connection/connection-min.js"></script> <vb:else /> <script type="text/javascript" src="{vb:stylevar yuipath}/yuiloader-dom-event/yuiloader-dom-event.js"></script> </vb:if> </vb:if> <script type="text/javascript"> <!-- if (typeof YAHOO === 'undefined') // Load ALL YUI Local { document.write('<script type="text/javascript" src="clientscript/yui/yuiloader-dom-event/yuiloader-dom-event.js?v={vb:raw vboptions.simpleversion}"><\/script>'); document.write('<script type="text/javascript" src="clientscript/yui/connection/connection-min.js?v={vb:raw vboptions.simpleversion}"><\/script>'); var yuipath = 'clientscript/yui'; var yuicombopath = ''; var remoteyui = false; } else // Load Rest of YUI remotely (where possible) { var yuipath = '{vb:stylevar yuipath}'; var yuicombopath = '{vb:stylevar yuicombopath}'; var remoteyui = true; if (!yuicombopath) { document.write('<script type="text/javascript" src="{vb:stylevar yuipath}/connection/connection-min.js?v={vb:raw vboptions.simpleversion}"><\/script>'); } } var SESSIONURL = "{vb:raw session.sessionurl_js}"; var SECURITYTOKEN = "{vb:raw bbuserinfo.securitytoken}"; var IMGDIR_MISC = "{vb:stylevar imgdir_misc}"; var IMGDIR_BUTTON = "{vb:stylevar imgdir_button}"; var vb_disable_ajax = parseInt("{vb:raw vboptions.disable_ajax}", 10); var SIMPLEVERSION = "{vb:raw vboptions.simpleversion}"; var BBURL = "{vb:raw vboptions.bburl}"; var LOGGEDIN = {vb:raw bbuserinfo.userid} > 0 ? true : false; var THIS_SCRIPT = "{vb:raw this_script}"; var RELPATH = "{vb:raw relpath}"; var PATHS = { forum : "{vb:raw vboptions.vbforum_url}", cms : "{vb:raw vboptions.vbcms_url}", blog : "{vb:raw vboptions.vbblog_url}" }; var AJAXBASEURL = "{vb:raw ajaxbaseurl}"; // --> </script> <script type="text/javascript" src="{vb:raw vboptions.bburl}/clientscript/vbulletin-core.js?v={vb:raw vboptions.simpleversion}"></script> {vb:raw template_hook.headinclude_javascript} <vb:if condition="$vboptions['externalrss']"> <link rel="alternate" type="application/rss+xml" title="{vb:raw vboptions.bbtitle} {vb:rawphrase rss_feed}" href="{vb:raw vboptions.bburl}/external.php?type=RSS2" /> <vb:if condition="$show['foruminfo'] OR $show['threadinfo']"> <link rel="alternate" type="application/rss+xml" title="{vb:raw vboptions.bbtitle} - {vb:raw foruminfo.title_clean} - {vb:rawphrase rss_feed}" href="{vb:raw vboptions.bburl}/external.php?type=RSS2&forumids={vb:raw foruminfo.forumid}" /> </vb:if> </vb:if> <vb:if condition="$vboptions['storecssasfile']"> {vb:cssfile main-rollup.css} {vb:raw template_hook.custom_css_links} <vb:else /> {vb:cssfile bbcode.css,editor.css,popupmenu.css,reset-fonts.css,vbulletin.css,vbulletin-chrome.css,vbulletin-formcontrols.css{vb:raw template_hook.custom_css_list}} </vb:if> <!--[if lt IE 8]> {vb:cssfile popupmenu-ie.css,vbulletin-ie.css,vbulletin-chrome-ie.css,vbulletin-formcontrols-ie.css,editor-ie.css} <![endif]--> {vb:raw template_hook.headinclude_css} <!-- google cse --> <script> (function() { var cx = '014891898195566079264:j9p1m_ucz0q'; ///////////////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="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']"> <form action="http://www.hobby-machinist.com/google.php" id="cse-search-box"> <input type="hidden" name="cx" value="'014891898195566079264:j9p1m_ucz0q'" /> <input type="hidden" name="cof" value="FORID:9" /> <input type="hidden" name="ie" value="ISO-8859-1" /> <span class="searchBox_container"><input type="text" value="" class="textbox" name="q" tabindex="99"/></span> <span class="searchBox_button"><input type="image" src="images/styles/BlueDemon/buttons/search.png" name="submit" onclick="document.getElementById('navbar_search').submit;" tabindex="100"/></span> </form> <script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&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="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> {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="do" value="dismissnotice" /> <input type="hidden" name="s" value="{vb:raw session.sessionurl}" /> <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" /> <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> 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('' => 'Google Site Search')); $navbar = render_navbar_template($navbits); // ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = 'Google 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()); ?> It ALWAYS goes to the Google Custom Search Page. Help, PLEASE! Thanks! Nelson |
#194
|
|||
|
|||
Can anyone help me on this please?
Thanks, Nelson |
#195
|
|||
|
|||
Okay I have a good one for you. Custom search works fine but when the results display on my page the links cannot be clicked, they are underlined but don't seem to be working.
fixed: it appears that I had an iframe height value that was locking things up making the hyperlinks real slow to show up. |
#196
|
|||
|
|||
Does anyone know how to incorporate custom search into a forum block? I'd like to have the search box in a block at the top of my sidebar if that's possible?
|
#197
|
||||
|
||||
Quote:
Just add the code to an html block. I believe you have to add one portion of the code to your header or head includes as well. |
#198
|
|||
|
|||
Thanks very much. I'll give that a go :up:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|