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)

Verionia 12-30-2009 12:14 AM

- What do I replace with value="FORID:10"?
- Also how can I create a vbulletin page for the results to show?

SemperFideles 12-31-2009 08:28 PM

I'm stuck. I've followed all the instructions and created a site search page from my Adsense account. I get a blank page from my search results.

My google.php looks like this:
PHP Code:

<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

Should I have anything else in the file?

SemperFideles 12-31-2009 08:31 PM

I guess what I'm asking is if the google.php should have any other code within it? Should I just create a new file called google.php, paste the above code to it and then upload it or should there be some other code before and after it so it will display inline?

bpr 01-01-2010 02:49 PM

Quote:

Originally Posted by SemperFideles (Post 1943598)
I'm stuck. I've followed all the instructions and created a site search page from my Adsense account. I get a blank page from my search results.

My google.php looks like this:
PHP Code:

<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

Should I have anything else in the file?

Dito guys, and I can not find the mistake :(

Dave-ahfb 01-01-2010 03:17 PM

The code for your search results page looks fine. I have to ask if it may have been a case of "give google 10 minutes to update"? If not, make certain your form is calling the proper file. If the form call is correct paste the important part of your form here and I will check it out.

SemperFideles 01-01-2010 06:03 PM

Here is the process I used to create a custom search results page. You can see the search in operation at http://www.puritanboard.com

1. In your Adsense Setup page for your Custom Search
  • Select Only sites I select
  • Type your URL (without http:/)
  • Select Use Safe Search (to avoid explicit content)
  • Under Open Search Results Page select Open results within my own site
  • In the block type http://www.yourforum.com/google.php
  • The rest of the settings you can figure out

2. Create a file called google.php to upload to your forum root. Here are my contents
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 #####
$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());

?>

3. Go to your AdminCP
  • Go to Styles & Templates -> Style Manager
  • Within your Style pulldown select Create New Templat
  • Name the Template GOOGLE
  • Paste the following code within:

PHP 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

4. Make the modifications to navbar as described herein. Here is my entire form within Navbar so you can see how mine was implemented (Google Adsense code modified):

PHP Code:

<form action="http://www.puritanboard.com/google.php" id="cse-search-box">
    <
input type="hidden" name="cx" value="partner-pub-xxxxxxxxxxx:xxxxxx-xxxx" />
    <
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


vivamexico55 01-02-2010 04:16 AM

Semper, thanks! When you comment "// ###### YOUR CUSTOM CODE GOES HERE #####"
Are you referring to the Search Results Code? And where exactly do we paste it?

Or do we just paste everything into google.php without modifying anything? If I do that, I get a blank page.

thanks!

SemperFideles 01-02-2010 12:56 PM

No, you do not need to make any modifications to google.php. You can copy, paste, and save exactly as above. The only customization you need to make above is to Step 4. You can customize Step 3 by making the frame width for search higher but that's minor.

Regarding Step 4, when you go to Google Adsense in Step 1 to create your Custom Search (be sure to save that Custom Search), then you will be able to get the code you need from Google so your particular code is inserted where the XX's are in my example.

If you're getting a blank page then either you have not created the Template (Step 3) or you have not modified the navbar template correctly (Step 4). You should be able to test google.php out just by visiting the page. You'll see that the page works even if there are no search results. Also, make sure to set the file permissions to 755 for google.php

vivamexico55 01-02-2010 06:02 PM

Thank you SO MUCH Semper! It is indeed working now, with the default google.php you supplied, my mistake was trying to add the code in there. Again, thanks =)

volarium 01-06-2010 01:48 AM

Quote:

Originally Posted by SemperFideles (Post 1944185)
Here is the process I used to create a custom search results page.

Thanks for posting this, it made it very easy to implement.


All times are GMT. The time now is 01:43 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.01225 seconds
  • Memory Usage 1,793KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)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