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)

Dave-ahfb 11-30-2009 10:00 PM

Replace search with Google Custom Search
 
1 Attachment(s)
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:

<form action="search.php?do=process" method="post" id="navbar_search"


replace with the form line of the google supplied code
example:
PHP Code:

<form action="http://www.ahfb2000.com/google.php" id="cse-search-box"



find
PHP Code:

<input type="hidden" name="s" value="{vb:raw session.sessionurl}" />
<
input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
<
input type="hidden" name="do" value="process" /> 


replace with the first 3 hidden input types in your google code
example:
PHP Code:

    <input type="hidden" name="cx" value="partner-pub-xxxxxxxxxxxxxxxxxxxxxxx" />
    <
input type="hidden" name="cof" value="FORID:10" />
    <
input type="hidden" name="ie" value="ISO-8859-1" /> 



find
PHP Code:

<input type="text" value="" name="query" class="textbox" /> 


replace with
PHP Code:

<input type="text" value="" name="q" class="textbox" /> 



find
PHP Code:

<input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search.png" name="submit" onclick="document.getElementById('navbar_search').submit;" /> 


replace with
PHP Code:

<input type="image" class="searchbutton" src="{vb:stylevar imgdir_button}/search.png" name="sa" onclick="document.getElementById('navbar_search').submit;" /> 



find
PHP Code:

</form


add this after
PHP Code:

<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script


Dave-ahfb 12-01-2009 11:11 AM

Can a mod move this to vb 4 forums please

Arcade Fire 12-01-2009 02:19 PM

Thanks, installed.

abdobasha2004 12-02-2009 12:43 PM

wanted for 3.7 !

SİMAR 12-02-2009 09:40 PM

Thanks,

Dr.osamA 12-03-2009 12:53 PM

try try

installed
thnxxxx man
________
Masturbation School

g00gl3r 12-07-2009 06:44 PM

Reserved.

rtyagis 12-11-2009 01:36 PM

Reserved.

Tize. 12-12-2009 08:14 PM

Hello I have installed but when I give him a look I get this error.
I have made everything as you said.
Thank you.

HTML Code:

Not Found

The requested URL /google.php was not found on this server.
Apache/2.2.3 (CentOS) Server at www.ddirecta.com Port 80


Dave-ahfb 12-12-2009 08:34 PM

Read the instructions again. Some of the "replace" codes are examples and not to be taken literal.

Tize. 12-12-2009 08:42 PM

According thank you very much I will look again.
Greetings.

Tize. 12-12-2009 08:54 PM

Hello again, my forum have 2
HTML Code:

</form>
The correct code for this is ?
HTML Code:

</form><script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en">
This is my code, sorry for the inconvennience.

HTML Code:

<div class="above_body">
<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:if condition="!$vboptions['selectednavtab'] AND THIS_SCRIPT != 'search'">
                        <li class="selected"><a class="navtab" href="{vb:raw vboptions.forumhome}.php{vb:raw session.sessionurl_q}">{vb:rawphrase forum}</a>
                                <ul class="floatcontainer">
                                        {vb:raw template_hook.navbar_start}
                                        <vb:if condition="$show['searchbuttons']">
                                                <vb:if condition="$show['member']">
                                                <li><a href="search.php?{vb:raw session.sessionurl}do=getnew&amp;contenttype=vBForum_Post">{vb:rawphrase new_posts_nav}</a></li>
                                                <vb:else />
                                                <li><a href="search.php?{vb:raw session.sessionurl}do=getdaily&amp;contenttype=vBForum_Post">{vb:rawphrase todays_posts}</a></li>
                                                </vb:if>
                                        </vb:if>
                                        {vb:raw template_hook.navbar_after_getnew}
                                        <vb:if condition="$show['pmmainlink']">
                                                <li><a href="private.php{vb:raw session.sessionurl_q}" rel="nofollow">{vb:rawphrase private_messages}</a></li>
                                        </vb:if>
                                        {vb:raw template_hook.navbar_after_pm}
                                        <li><a rel="help" href="faq.php{vb:raw session.sessionurl_q}">{vb:rawphrase faq}</a></li>
                                        {vb:raw template_hook.navbar_after_faq}
                                        <li><a href="calendar.php{vb:raw session.sessionurl_q}">{vb:rawphrase calendar}</a></li>
                                        {vb:raw template_hook.navbar_after_calendar}

                                        <li class="popupmenu">
                                                <a href="javascript://" class="popupctrl">{vb:rawphrase community}</a>
                                                <ul class="popupbody popuphover">
                                                        {vb:raw template_hook.navbar_community_menu_start}
                                                        <vb:if condition="$show['quick_links_groups']">
                                                                <li><a href="group.php{vb:raw session.sessionurl_q}">{vb:rawphrase social_groups}</a></li>
                                                        </vb:if>
                                                        <vb:if condition="$show['quick_links_albums']">
                                                                <li><a href="album.php{vb:raw session.sessionurl_q}">{vb:rawphrase pictures_and_albums}</a></li>
                                                        </vb:if>
                                                        <vb:if condition="$bbuserinfo['userid']">
                                                                <li><a href="profile.php?{vb:raw session.sessionurl}do=buddylist"><vb:if condition="$show['friends_and_contacts']">{vb:rawphrase contacts_and_friends}<vb:else />{vb:rawphrase contacts}</vb:if></a></li>
                                                        </vb:if>
                                                        <vb:if condition="$show['memberslist']">
                                                                <li><a href="memberlist.php{vb:raw session.sessionurl_q}">{vb:rawphrase members_list}</a></li>
                                                        </vb:if>
                                                        {vb:raw template_hook.navbar_community_menu_end}
                                                </ul>
                                        </li>
                                        {vb:raw template_hook.navbar_after_community}
                                        <li class="popupmenu">
                                                <a href="javascript://" class="popupctrl">{vb:rawphrase forum_actions}</a>
                                                <ul class="popupbody popuphover">
                                                        <li>
                                                                <a href="forumdisplay.php?{vb:raw session.sessionurl}do=markread">{vb:rawphrase mark_forums_read}</a>
                                                        </li>
                                                        <vb:if condition="$show['member']">
                                                        <li>
                                                                <a href="profile.php?{vb:raw session.sessionurl}do=editoptions">{vb:rawphrase edit_options}</a>
                                                        </li>
                                                        <li>
                                                                <a href="profile.php?{vb:raw session.sessionurl}do=editprofile">{vb:rawphrase edit_your_details}</a>
                                                        </li>
                                                        </vb:if>
                                                </ul>
                                        </li>
                                        <li class="popupmenu">
                                                <a href="javascript://" class="popupctrl">{vb:rawphrase quick_links}</a>
                                                <ul class="popupbody popuphover">
                                                        <vb:if condition="$show['member']">
                                                        <vb:if condition="$show['member']">
                                                                <li><a href="subscription.php{vb:raw session.sessionurl_q}" rel="nofollow">{vb:rawphrase subscribed_threads}</a></li>
                                                        </vb:if>
                                                        <li>
                                                                <a href="javascript://" onclick="window.open(getBaseUrl() + 'misc.php?{vb:raw session.sessionurl}do=buddylist&amp;focus=1','buddylist','statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=250,height=300'); return false;">{vb:rawphrase open_contacts}</a>
                                                        </li>
                                                        </vb:if>
                                                        <vb:if condition="$vboptions['forumleaders']">
                                                        <li><a href="showgroups.php{vb:raw session.sessionurl_q}" rel="nofollow">
                <vb:if condition="$vb_suite_installed">
                        {vb:rawphrase view_site_leaders}
                <vb:else />
                        {vb:rawphrase view_forum_leaders}
                </vb:if>
        </a></li>
                                                        </vb:if>
                                                        {vb:raw template_hook.navbar_quick_links_menu_pos1}
                                                        {vb:raw template_hook.navbar_quick_links_menu_pos2}
                                                        {vb:raw template_hook.navbar_quick_links_menu_pos3}
                                                        <vb:if condition="$show['wollink']">
                                                                <li><a href="online.php{vb:raw session.sessionurl_q}">{vb:rawphrase whos_online}</a></li>
                                                        </vb:if>
                                                        {vb:raw template_hook.navbar_quick_links_menu_pos4}
                                                </ul>
                                        </li>
                                        {vb:raw template_hook.navbar_end}
                                </ul>

                        </li>
                <vb:elseif condition="$vboptions['selectednavtab']=='usercp'" />
                        <li class="selected"><a class="navtab" href="{vb:raw vboptions.forumhome}.php{vb:raw session.sessionurl_q}">{vb:rawphrase forum}</a>
                                <ul class="floatcontainer">
                                        {vb:raw template_hook.navbar_start}
                                        <vb:if condition="$show['searchbuttons']">
                                                <vb:if condition="$show['member']">
                                                <li><a href="search.php?{vb:raw session.sessionurl}do=getnew&amp;contenttype=vBForum_Post">{vb:rawphrase new_posts_nav}</a></li>
                                                <vb:else />
                                                <li><a href="search.php?{vb:raw session.sessionurl}do=getdaily&amp;contenttype=vBForum_Post">{vb:rawphrase todays_posts}</a></li>
                                                </vb:if>
                                        </vb:if>
                                        {vb:raw template_hook.navbar_after_getnew}
                                        <vb:if condition="$show['pmmainlink']">
                                                <li><a href="private.php{vb:raw session.sessionurl_q}" rel="nofollow">{vb:rawphrase private_messages}</a></li>
                                        </vb:if>
                                        {vb:raw template_hook.navbar_after_pm}
                                        <li><a rel="help" href="faq.php{vb:raw session.sessionurl_q}">{vb:rawphrase faq}</a></li>
                                        {vb:raw template_hook.navbar_after_faq}
                                        <li><a href="calendar.php{vb:raw session.sessionurl_q}">{vb:rawphrase calendar}</a></li>
                                        {vb:raw template_hook.navbar_after_calendar}
                                        <li class="popupmenu">
                                                <a href="javascript://" class="popupctrl">{vb:rawphrase community}</a>
                                                <ul class="popupbody popuphover">
                                                        {vb:raw template_hook.navbar_community_menu_start}
                                                        <vb:if condition="$show['quick_links_groups']">
                                                                <li><a href="group.php{vb:raw session.sessionurl_q}">{vb:rawphrase social_groups}</a></li>
                                                        </vb:if>
                                                        <vb:if condition="$show['quick_links_albums']">
                                                                <li><a href="album.php{vb:raw session.sessionurl_q}">{vb:rawphrase pictures_and_albums}</a></li>
                                                        </vb:if>
                                                        <vb:if condition="$bbuserinfo['userid']">
                                                                <li><a href="profile.php?{vb:raw session.sessionurl}do=buddylist"><vb:if condition="$show['friends_and_contacts']">{vb:rawphrase contacts_and_friends}<vb:else />{vb:rawphrase contacts}</vb:if></a></li>
                                                        </vb:if>
                                                        <vb:if condition="$show['memberslist']">
                                                                <li><a href="memberlist.php{vb:raw session.sessionurl_q}">{vb:rawphrase members_list}</a></li>
                                                        </vb:if>
                                                        {vb:raw template_hook.navbar_community_menu_end}
                                                </ul>
                                        </li>
                                        {vb:raw template_hook.navbar_after_community}
                                        <li class="popupmenu">
                                                <a href="javascript://" class="popupctrl">{vb:rawphrase forum_actions}</a>
                                                <ul class="popupbody popuphover">
                                                        <li>
                                                                <a href="forumdisplay.php?{vb:raw session.sessionurl}do=markread">{vb:rawphrase mark_forums_read}</a>
                                                        </li>
                                                        <vb:if condition="$show['member']">
                                                        <li>
                                                                <a href="profile.php?{vb:raw session.sessionurl}do=editoptions">{vb:rawphrase edit_options}</a>
                                                        </li>
                                                        <li>
                                                                <a href="profile.php?{vb:raw session.sessionurl}do=editprofile">{vb:rawphrase edit_your_details}</a>
                                                        </li>
                                                        </vb:if>
                                                </ul>
                                        </li>
                                        <li class="popupmenu">
                                                <a href="javascript://" class="popupctrl">{vb:rawphrase quick_links}</a>
                                                <ul class="popupbody popuphover">
                                                        <li><a href="subscription.php{vb:raw session.sessionurl_q}" rel="nofollow">{vb:rawphrase subscribed_threads}</a></li>
                                                        <li>
                                                                <a href="javascript://" onclick="window.open(getBaseUrl() + 'misc.php?{vb:raw session.sessionurl}do=buddylist&amp;focus=1','buddylist','statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=250,height=300'); return false;">{vb:rawphrase open_contacts}</a>
                                                        </li>
                                                        <vb:if condition="$vboptions['forumleaders']">
                                                        <li>
                                                                <a href="showgroups.php{vb:raw session.sessionurl_q}" rel="nofollow">
                <vb:if condition="$vb_suite_installed">
                        {vb:rawphrase view_site_leaders}
                <vb:else />
                        {vb:rawphrase view_forum_leaders}
                </vb:if>
        </a>
                                                        </li>
                                                        </vb:if>
                                                        {vb:raw template_hook.navbar_quick_links_menu_pos1}
                                                        {vb:raw template_hook.navbar_quick_links_menu_pos2}

                                                        {vb:raw template_hook.navbar_quick_links_menu_pos3}

                                                        <vb:if condition="$show['wollink']">
                                                                <li><a href="online.php{vb:raw session.sessionurl_q}">{vb:rawphrase whos_online}</a></li>
                                                        </vb:if>
                                                        {vb:raw template_hook.navbar_quick_links_menu_pos4}
                                                </ul>
                                        </li>
                                        {vb:raw template_hook.navbar_end}
                                </ul>
                        </li>
                <vb:else />
                        <li><a class="navtab" href="{vb:raw vboptions.forumhome}.php{vb:raw session.sessionurl_q}">{vb:rawphrase forum}</a></li>
                </vb:if>
                {vb:raw template_hook.navtab_middle}
                <vb:if condition="!$vboptions['selectednavtab'] AND THIS_SCRIPT == 'search'">
                        <vb:if condition="$show['member']">
                        <li  class="selected"><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getnew&amp;contenttype=vBForum_Post">{vb:rawphrase getnew_tab}</a>
                                <ul class="floatcontainer">
                                        <li><a href="search.php?{vb:raw session.sessionurl}do=getnew&amp;contenttype=vBForum_Post">{vb:rawphrase new_posts_nav}</a></li>
                                        <li><a href="search.php?{vb:raw session.sessionurl}do=getnew&amp;contenttype=vBForum_SocialGroupMessage">{vb:rawphrase new_group_messages_nav}</a></li>
                                        <li><a href="search.php?{vb:raw session.sessionurl}do=getnew&amp;contenttype=vBForum_Event">{vb:rawphrase new_events_nav}</a></li>
                                        {vb:raw template_hook.navbar_getnew_menu}
                                        <li><a href="forumdisplay.php?{vb:raw session.sessionurl}do=markread">{vb:rawphrase mark_forums_read}</a></li>
                                </ul>
                        </li>
                        <vb:else />
                        <li  class="selected"><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getdaily&amp;contenttype=vBForum_Post">{vb:rawphrase getnew_tab}</a>
                                <ul class="floatcontainer">
                                        <li><a href="search.php?{vb:raw session.sessionurl}do=getdaily&amp;contenttype=vBForum_Post">{vb:rawphrase todays_posts}</a></li>
                                        <li><a href="search.php?{vb:raw session.sessionurl}do=getdaily&amp;contenttype=vBForum_SocialGroupMessage">{vb:rawphrase daily_group_message}</a></li>
                                        <li><a href="search.php?{vb:raw session.sessionurl}do=getdaily&amp;contenttype=vBForum_Event">{vb:rawphrase daily_events}</a></li>
                                        {vb:raw template_hook.navbar_getdaily_menu}
                                        <li><a href="forumdisplay.php?{vb:raw session.sessionurl}do=markread">{vb:rawphrase mark_forums_read}</a></li>
                                </ul>
                        </li>
                        </vb:if>
                <vb:elseif condition="$show['member']" />
                        <li><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getnew&amp;contenttype=vBForum_Post">{vb:rawphrase getnew_tab}</a></li>
                <vb:else />
                        <li><a class="navtab" href="search.php?{vb:raw session.sessionurl}do=getdaily&amp;contenttype=vBForum_Post">{vb:rawphrase getnew_tab}</a></li>
                </vb:if>
                {vb:raw template_hook.navtab_end}
        </ul>

        <vb:if condition="$vboptions['enablesearches']">
        <div id="globalsearch" class="globalsearch">
                <form action="http://www.ddirecta.com/google.php" id="cse-search-box">
                        <input type="hidden" name="cx" value="partner-pub-0438788898968784188" />
    <input type="hidden" name="cof" value="FORID:10" />
    <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}">{vb:rawphrase advanced_search}</a></li>
                </ul>
        </div>
        </vb:if>
</div>
</div>

<div class="breadcrumbcontainer">
<div id="breadcrumb" class="breadcrumb">
        <ul class="floatcontainer">
                <li class="navbithome"><a href="index.php{vb:raw session.sessionurl_q}" ><img src="images/misc/navbit-home.png" alt="Home" /></a></li>

                {vb:raw navbits.breadcrumb}
                {vb:raw navbits.lastelement}
        </ul>
        <hr />
</div>
</div>

{vb:raw ad_location.ad_navbar_below}
{vb:raw ad_location.global_below_navbar}

<vb:if condition="$show['notices']">
        <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><script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script> 
</vb:if>


Dave-ahfb 12-12-2009 09:00 PM

Place the <script> line only after the first </form>.

Your second closing form tag is for <form action="profile.php?do=dismissnotice" method="post" id="notices" class="notices">

Tize. 12-12-2009 09:19 PM

Hello, thank you very much for your help but is not happening does not.
I'm sorry if I trouble you with my questions.
But this code is a bit complicated.
I'm really sorry. Still thank you very much for your help you are very kind.
I will leave that always fails. I do not understand what happens but anyway thank you very much indeed.

Greetings.

Dave-ahfb 12-12-2009 09:22 PM

Is your result page titled google.php or did you give it another name? Again, my use of google.php was an EXAMPLE, you should use the name of the page that YOU created for google search.

Tize. 12-12-2009 09:33 PM

From the Google page I have not downloaded anything, just the robot.txt and ID code

Dave-ahfb 12-12-2009 09:43 PM

This is meant for people that use google adsense for search, if you have not completed the steps specified by Google this will not work for you.

Tize. 12-12-2009 09:53 PM

Thank you very much sir, I will complete the registration to see if they give me some code to complete.
Thank you very much and apologize for the inconvenience.
Greetings.

SnakeV 12-16-2009 09:06 PM

Can post your google.php file?

Dave-ahfb 12-16-2009 09:21 PM

Quote:

Originally Posted by SnakeV (Post 1931876)
Can post your google.php file?

Google gives you a script for this when you set up adsense for search.

alFaris.NET 12-21-2009 05:27 PM

thanx man

saviola8x 12-23-2009 01:49 PM

Quote:

replace with the form line of the google supplied code
i dont understand ? where is the file google.php ?

Dave-ahfb 12-23-2009 02:01 PM

Your quote answered your question

Quote:

replace with the form line of the google supplied code

saviola8x 12-23-2009 05:39 PM

But where is the google supplied code ?
i dont see it . Help me, pls .

Dave-ahfb 12-23-2009 05:49 PM

Quote:

Originally Posted by saviola8x (Post 1936634)
But where is the google supplied code ?
i dont see it . Help me, pls .

https://www.google.com/adsense/

KissOfDeath 12-24-2009 07:31 PM

Thanks a lot, it works great although the google watermark isn't showing on mine like it is on yours (yes i did select the right option when setting it up in google) no problem though it still opens up to my custom search page when you do a search

Dave-ahfb 12-24-2009 08:51 PM

Quote:

Originally Posted by KissOfDeath (Post 1937521)
Thanks a lot, it works great although the google watermark isn't showing on mine like it is on yours (yes i did select the right option when setting it up in google) no problem though it still opens up to my custom search page when you do a search

Be sure to add
Quote:

<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script>
after </form>

KissOfDeath 12-24-2009 11:39 PM

Quote:

Originally Posted by Dave-ahfb (Post 1937586)
Be sure to add after </form>

actually i think i'll leave it as it is, i've read a load of how to make money from google stuff and it all boils down to 1 thing:

Disguise you adds as much as possible so they look like your site so your tricking people into clicking on them thinking it's part of your site, i think the same goes for this mod their more likely to use it if they think it's an internal search engine, it practically is if you set it up through adsense to search you site only...


Now all need is the mod to add adsense to the postbit for vb4

Dave-ahfb 12-25-2009 02:44 AM

As long as you are aware thast you could lose your adsense account as well as all earnings.

Welshy2008 12-27-2009 12:33 PM

Would it be possible to have this AS WELL as the vB Search?

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 04:54 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.01757 seconds
  • Memory Usage 2,068KB
  • 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
  • (4)bbcode_html_printable
  • (15)bbcode_php_printable
  • (9)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
  • (40)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