vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=246)
-   -   Integration with vBulletin - Replace search with Google Custom Search (https://vborg.vbsupport.ru/showthread.php?t=229247)

slcousin 05-28-2013 02:08 PM

Confirmed working on 4.2 as per SemperFideles instructions:

http://www.supermotoforum.co.uk/

Thanks for the help!

Lpspider 06-01-2013 06:38 AM

Managed to get this working with two issues:

- it breaks my header style - logo not showing up, forumhome sidebar shows on the bottom of the page, and it shows a large blank space below the results.

fxdigi-cash 06-23-2013 06:58 PM

Thanks first for the great effort and trying to share the good stuff...

I believe there is something missing here, which is google.php connection to the search box. I tested your way, but not really working as I expected. It opens new page on google search while actually we want the search to be taking place in the forum itself using the google.php...

what I did is the following:

1- created google.php "or whatever you like to call it"
2- created a template for google search as mentioned earlier.
3- placed google script in headeinclude template from my google custom search similar to this one:
Code:

<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>

4- in the navtab, I edited the source in
Code:

<form action
.... vb code for search box + button
</form>

to this:
Code:

<form method="get" action="http://www.YOUR VB LINK.com/google.php" target="_blank" class="navbar_search">
            <input type="hidden" name="sitesearch" value="YOUR VB LINK.com"  id="pn"/>
            <span class="textboxcontainer"><span><input type="text" value="" name="q" class="textbox" tabindex="99"/></span></span>
            <span class="buttoncontainer"><span><input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search.png" name="submit" style="border:0; margin-left:5px;" onclick="document.getElementById('navbar_search').submit;" tabindex="100"/></span></span>
        <input type="hidden" name="domains" value="YOUR VB LINK.com"/>
</form>

replace the red tag with your forum url.

5- Last step, I added <gcse:search></gcse:search> in my google.php custom page...

Save the whole work and check it out...

I tested it and works perfect.

Thanks, and good luck. :)

Quote:

Originally Posted by svensonsan (Post 2408469)
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;
}



SimonB 07-28-2013 11:03 AM

Quote:

Originally Posted by fxdigi-cash (Post 2430025)
Thanks first for the great effort and trying to share the good stuff...

I believe there is something missing here, which is google.php connection to the search box. I tested your way, but not really working as I expected. It opens new page on google search while actually we want the search to be taking place in the forum itself using the google.php...

what I did is the following:

Thanks for posting this update.

It works fine for my site although i had to make a couple of style mods.

My one question is: I have linked my CSE to my Adsense Account, but the ads are not displaying in the search results page, although adsense is working perfectly on my actual site. Is this an adsense problem, or is there something I still need to do?

fxdigi-cash 07-28-2013 12:04 PM

I have no idea how that should work, sorry about that, mate

amogh 09-27-2013 05:43 AM

The mod is working great on VB 4.2

However I have an issue. It is working ONLY on the custom theme and not on the default theme.

Any idea how do I fix this?

Thanks

Charis 04-12-2014 09:09 AM

I followed the instructions but doesn't work (eMesitis.gr vB4.2.2).
Unfortunately I get a blank page.
I would appreciate any help.:)

1) I created a new Template called "GOOGLE":
PHP Code:

<div class="blockrow">
    <
gcse:search></gcse:search>
</
div

2) I created a "google.php" page. (I added <gcse:search></gcse:search> as you can see)
PHP 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 #####
<script>
$pagetitle 'Google Custom Search';
<
gcse:search></gcse: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());

?>

I added the following code to the end of "headinclude" template:
PHP Code:

<!-- google CSE -->
<
script>
  (function() {
    var 
cx '<script>
  (function() {
    var cx = '
partner-pub-6928381629786967:3340711439';
    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 document.getElementsByTagName('script')[0];
    
s.parentNode.insertBefore(gcses);
  })();
</
script>
<!-- 
google CSE  --> 

I replaced the
PHP Code:

<form action .... (vb code for search box button) ... </form

in "navbar" template with the following code:
PHP Code:

<form method="get" action="http://www.emesitis.gr/google.php" target="_blank" class="navbar_search">
            <
input type="hidden" name="sitesearch" value="emesitis.gr"  id="pn"/>
            <
span class="textboxcontainer"><span><input type="text" value="" name="q" class="textbox" tabindex="99"/></span></span>
            <
span class="buttoncontainer"><span><input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search.png" name="submit" style="border:0; margin-left:5px;" onclick="document.getElementById('navbar_search').submit;" tabindex="100"/></span></span>
        <
input type="hidden" name="domains" value="emesitis.gr"/>
</
form

Finally, I added the following code into "additional.css" template:
PHP 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;



ramesh_umk3 04-12-2014 05:01 PM

See mostly is happens when your running site on folder of root server..

In Google.php file uncomment below line
Quote:

// chdir ('/path/to/your/forums'); (And mention your site path)
Regards,

Charis 04-14-2014 05:40 AM

Thanks mate but it didn't work.
I found my forum path using the following php:
PHP Code:

 <?php
echo getcwd();

So my forum path is: /home3/emesitis/public_html

After that I followed your instructions and uncomment the path line in google.php:
PHP Code:

chdir ('/home3/emesitis/public_html'); 

I still have a complete blank page.

In google.php there are three lines:
PHP Code:

define('THIS_SCRIPT''test');
define('CSRF_PROTECTION'true);  
// change this depending on your filename 

Which filename?
Should I change the 'test' on the first line?

ramesh_umk3 04-14-2014 12:38 PM

try to create only test.php there were some tutorials here see you have blank page on that too . If you have same problem on test.php then tell your host to fix permissions on your account
cause the problem you would be getting is 500 internal server error which would be either permission or path error


All times are GMT. The time now is 04:09 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.02691 seconds
  • Memory Usage 1,824KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_code_printable
  • (9)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete