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)

hiker 05-17-2011 08:11 PM

Is there a way to exclude certain forums from coming up in the search results?

I'd like to exclude my forum id 61 for example.

I assume it'd have to be something like &exclude=61 somewhere in the code but I can't seem to get it. :confused:

SemperFideles 05-17-2011 09:03 PM

Quote:

Originally Posted by bogley (Post 2196866)
Is there a way to exclude certain forums from coming up in the search results?

I'd like to exclude my forum id 61 for example.

I assume it'd have to be something like &exclude=61 somewhere in the code but I can't seem to get it. :confused:

The only way to exclude a forum is to make it a member's only or hidden forum. If Google is crawling it then it will show up in results.

deverill2010 05-18-2011 05:21 AM

Is there anyway to customise this so that you have two radio buttons one for "site" one for "www".

When site is selected the keywords are searched through the normal VB search system and results returned within a page.

When www is selected the keywords are searched through google and the results displayed in your VB page that this mod currently does.

What I'm having trouble with is settting up the two radio buttons so when either is selected it goes though the right search.

Anyone care to help?

I like this mod but am finding that the search results within my own site are poor, but I still want th opportunity to earn some money!

hiker 05-18-2011 06:39 PM

Quote:

Originally Posted by SemperFideles (Post 2196898)
The only way to exclude a forum is to make it a member's only or hidden forum. If Google is crawling it then it will show up in results.

Dang, I thought there was some way I could include an "exclude=59" or maybe some kind of "include only these forums" code.

Is there a way to make a forum non searchable, while still keeping it open to the public? Just a general option somehow?

EDIT:

Nevermind, I realized in Forum Manager, "Index New Posts in Search Engine " I just set that to No.

sross 05-29-2011 12:51 PM

My search results are not from my domain, but from the web. I have done everything in the instructions. Does it take a while for the search to kickin? Google shows most of my pages are indexed. Have I missed something? On the search setup I have specified my forums etc. Thanks

galerio 05-30-2011 09:14 PM

Very useful mod.
You can use conditional to make present the google search to unregistered/not logged users and the native vb search to logged users.

StonePilot 06-24-2011 05:50 PM

Quote:

Originally Posted by SemperFideles (Post 2178766)
There's nothing to update for the most recent vBulletin version. It works fine.

Anyone have a guide for a custom template mod? I am not able to get the header information and style to look right. The custom search page works, it's just broken the style.

Aerialporter 12-13-2011 05:01 PM

How do I rename the search.php without messing up any other code that references search.php?

alaska_av8r 01-02-2012 05:06 AM

I have this working on vB 4.1.8 and wonder if anyone has found out how to prevent it from showing adds above the search results. I would like to show them on the right side only because with the way it is currently set, it is extremely hard to differentiate between what is an add and what isn't.

Google has been crawling my site for over a year now so it has had time to index it pretty well, however when I search for common terms used on my site www.boatinghowto.com , it only shows one maybe two results, any ideas?

thanks

sspeed 04-02-2012 07:05 PM

Thanks, works beautifully, especially with the additions on page 3.

sportsoutlaw 04-28-2012 12:26 PM

just installed on 4.1.11 and works well.

lisa3876 07-09-2012 07:23 PM

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.

insidegames 07-21-2012 12:54 PM

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.

CountRock 10-27-2012 11:26 PM

Quote:

Originally Posted by insidegames (Post 2350120)
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!

g00gl3r 11-26-2012 02:46 PM

Does this show using an iframe within the site template? Or open in a new window?

techbytes 01-21-2013 06:43 PM

Quote:

Originally Posted by Winter Sonata (Post 2032033)
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

svensonsan 03-07-2013 09:37 AM

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


Spika 03-07-2013 12:08 PM

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

Works Perfect!!

Thank you very much! :D:D:D

simon661 03-30-2013 02:55 PM

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


http://www.railtransit-cbtc.com/CBTC...ity/forum.php?

beertruck 05-07-2013 04:00 AM

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

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

Charis 04-15-2014 07:42 AM

Thanks for your support.
Finally I solved my issues with this mod: https://vborg.vbsupport.ru/showthread.php?t=297548

Nelson58 09-21-2014 07:56 AM

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&amp;{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&amp;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 -->

The Navbar template:

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&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="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>

The google.php file in the root directory ( /public_html) :

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

Nelson58 09-22-2014 03:34 PM

Can anyone help me on this please?

Thanks,

Nelson

alaska_av8r 09-30-2014 11:20 PM

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.

stained 03-25-2015 04:27 PM

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?

RichieBoy67 03-25-2015 05:46 PM

Quote:

Originally Posted by stained (Post 2541513)
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?

https://support.google.com/customsea.../2630969?hl=en

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.

stained 03-26-2015 07:19 AM

Thanks very much. I'll give that a go :up:


All times are GMT. The time now is 11:14 AM.

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.01809 seconds
  • Memory Usage 2,030KB
  • 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
  • (19)bbcode_code_printable
  • (9)bbcode_php_printable
  • (10)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (37)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