vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Google Search Mod that Actually WORKS! (https://vborg.vbsupport.ru/showthread.php?t=314370)

Nelson58 09-17-2014 07:43 PM

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.

ozzy47 09-17-2014 09:40 PM

I assume you already have a Google CSE account?

CAG CheechDogg 09-17-2014 09:54 PM

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

ozzy47 09-17-2014 10:23 PM

Quote:

Originally Posted by CAG CheechDogg (Post 2515538)
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

Don't you need a Google CSE account for it to work?

tbworld 09-17-2014 10:32 PM

Quote:

Originally Posted by ozzy47 (Post 2515541)
Don't you need a Google CSE account for it to work?

Of course you do, as all Google site services. :)

ozzy47 09-17-2014 10:35 PM

That's what I thought, but I never used it so I was not sure. :)

CAG CheechDogg 09-17-2014 10:42 PM

Quote:

Originally Posted by ozzy47 (Post 2515541)
Don't you need a Google CSE account for it to work?

Yes you do ozzy ...

ozzy47 09-17-2014 10:50 PM

I wonder if Nelson has one, if he don't, it of course will not show. :)

tbworld 09-17-2014 10:55 PM

@nelson58, needs to spend a bit more time reading and asking more exacting questions. So far we are just messaging among ourselves. :)

CAG CheechDogg 09-17-2014 11:02 PM

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

Step 3: In your "navbar" template locate the following :

Code:

<div id="globalsearch" class="globalsearch">
Right below that remove the following code:

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>

and replace it with this :

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>

Then upload the following php file to your forums root:

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());

?>

In the php file above replace your site with your site's name and you should be good to go !!!!! If you have any questions feel free to ask away ...

--------------- Added [DATE]1410998655[/DATE] at [TIME]1410998655[/TIME] ---------------

Quote:

Originally Posted by tbworld (Post 2515546)
@nelson58, needs to spend a bit more time reading and asking more exacting questions. So far we are just messaging among ourselves. :)

Yes he does, but hopefully this will help him get this done lol .....:)


All times are GMT. The time now is 02:28 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.01229 seconds
  • Memory Usage 1,756KB
  • 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
  • (6)bbcode_code_printable
  • (4)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
  • (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