I have been worked on it and on my vb 4.0.1 community seem to work without problems, i post here my templates, the instructions are the same of Brian already posted:
step 1)
alter search_common template. here's my compelte template.
basically, you make a new if condition for guests and include the google code, else the default template:
The highlighted code comes from google's search and requires your adsense pub ID, so log into adsense and create a new search unit. you'll get similar code. just plug in your pub id, etc
The part in blue needs to be a custom made page. This acts as the 'wrapper' for the search results.Code:{vb:stylevar htmldoctype} <html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}"> <head> {vb:raw headinclude} <title>{vb:rawphrase advanced_search} - {vb:raw vboptions.bbtitle}</title> <link rel="stylesheet" type="text/css" href="{vb:var vbcsspath}tagcloud.css" /> <style type="text/css"> .savepreferences {float:{vb:stylevar left};text-align:{vb:stylevar left};width:49.5%;} </style> <script type="text/javascript" src="{vb:stylevar yuipath}/history/history-min.js"></script> <script type="text/javascript" src="clientscript/vbulletin_ajax_suggest.js?v={vb:raw vboptions.simpleversion}"></script> <script type="text/javascript" src="clientscript/vbulletin_ajax_search.js?v={vb:raw vboptions.simpleversion}"></script> <script src="clientscript/vbulletin_ajax_htmlloader.js?v={vb:raw vboptions.simpleversion}" type="text/javascript"></script> <script type="text/javascript"> function setAjax() { if (document.getElementById('userfield')) { snc = new vB_AJAX_NameSuggest('snc', 'userfield_txt', 'userfield'); } if (document.getElementById('tag_add')) { tag_add_comp = new vB_AJAX_TagSuggest('tag_add_comp', 'tag_add_input', 'tag_add'); } vB_AJAX_SearchPrefs_Init('save_searchprefs'); } </script> {vb:raw headinclude_bottom} </head> <body onload="setAjax()"> <iframe id="yui-history-iframe" src="{vb:stylevar yuipath}/history/assets/blank.html" style="position:absolute;top:0; {vb:stylevar left}:0;width:1px; height:1px;visibility:hidden;"></iframe> <input id="yui-history-field" type="hidden"> {vb:raw header} {vb:raw navbar} <vb:if condition="is_member_of($vbulletin->userinfo, 1,4)"> <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr> <td class="tcat">Search</td> </tr> <tr> <td class="alt1" style="text-align: center;"> <div id="guestbar">Welcome, Guest! Please <a href="register.php{vb:raw session.sessionurl_q}" rel="nofollow">{vb:rawphrase register}</a> or Login:<br /> <form action="login.php?{vb:raw session.sessionurl}do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, {vb:raw show.nopasswordempty})"> <script type="text/javascript" src="clientscript/vbulletin_md5.js?v={vb:raw vboptions.simpleversion}"></script> <input id="navbar_username" class="bginput" type="text" onblur="if (this.value == '') this.value = 'Username';" onfocus="if (this.value == 'Username') this.value = '';" value="Username" tabindex="101" accesskey="u" size="10" name="vb_login_username" style="font-size: 11px;"/> <input id="navbar_password" class="bginput" type="password" onblur="if (this.value == '') this.value = '';" onfocus="if (this.value == 'Password') this.value = '';" value="Password" tabindex="102" accesskey="u" size="10" name="vb_login_password" style="font-size: 11px;/> <label for="cb_cookieuser_navbar"> <input id="cb_cookieuser_navbar" type="checkbox" accesskey="c" tabindex="103" value="1" name="cookieuser" checked="checked"/> </label> <input type="submit" class="loginbutton" value="Login" tabindex="104" title="{vb:rawphrase enter_username_to_login_or_register}" accesskey="s" /> <input type="hidden" name="s" value="{vb:raw session.sessionhash}" /> <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" /> <input type="hidden" name="do" value="login" /> <input type="hidden" name="vb_login_md5password" /> <input type="hidden" name="vb_login_md5password_utf" /> </form> <br /> <p>Members have access to more features, better search, and see fewer ads! It's free, what are you waiting for?</p> </div> <br /> <br /> <form action="http://yourdomain.com/guestsearch.php" id="cse-search-box"> <div> <input type="hidden" name="cx" value="xxxxxxxxxxxxxxx" /> <input type="hidden" name="cof" value="xxxxxxxxxxxxxxx" /> <input type="hidden" name="ie" value="ISO-8859-1" /> <input type="text" name="q" size="31" /> <input type="submit" name="sa" value="Search" /> </div> </form> <script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script> <br /> <br /> </td> </tr> </table> <vb:else /> PUT THE REST OF THE CODE FOR THE 'GUTS' OF THE DEFAULT TEMPLATE HERE, STARTING WITH: <vb:if condition="$show['errors']"> AND ENDING WITH: <vb:if condition="$tag_cloud"> <div>{vb:raw tag_cloud}</div> </vb:if> </vb:if> {vb:raw footer} </body> </html>
It's a simple php script that does nothing more than call the 'skin' and a new custom search template.
guestsearch.php
Finally, add the new template:Code:<?php // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('THIS_SCRIPT', 'guestsearch'); 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('guestsearch', ); // pre-cache templates used by specific actions $actiontemplates = array(); // ######################### REQUIRE BACK-END ############################ require_once('./global.php'); // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### $navbits = construct_navbits(array('' => 'guestsearch')); $navbar = render_navbar_template($navbits); // ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = ''; // ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### $templater = vB_Template::create('guestsearch'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle); print_output($templater->render()); ?>
Again, most of this code comes directly from google.... so be sure to replace it with yours as given from the adsense setup.
template name: guestsearch
just add to the final custom CSS block in CSS Templates: (and change colors to match your skin if necessary)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>Search Engine - {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">Search Engine </h2> <div class="blockbody"> <div class="blockrow"> <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr> <td class="tcat">Search Results</td> </tr> <tr> <td class="searchres"> <br /> <div id="guestbar"> Welcome, Guest! <br /> Members have access to more features, <b>better search</b>, and see fewer ads! It's free, what are you waiting for?<br /><br /> Please <a href="register.php{vb:raw session.sessionurl_q}" rel="nofollow">{vb:rawphrase register}</a> or Login:<br /> <form action="login.php?{vb:raw session.sessionurl}do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, {vb:raw show.nopasswordempty})"> <script type="text/javascript" src="clientscript/vbulletin_md5.js?v={vb:raw vboptions.simpleversion}"></script> <input id="navbar_username" class="bginput" type="text" onblur="if (this.value == '') this.value = 'Username';" onfocus="if (this.value == 'Username') this.value = '';" value="Username" tabindex="101" accesskey="u" size="10" name="vb_login_username" style="font-size: 11px;"/> <input id="navbar_password" class="bginput" type="password" onblur="if (this.value == '') this.value = '';" onfocus="if (this.value == 'Password') this.value = '';" value="Password" tabindex="102" accesskey="u" size="10" name="vb_login_password" style="font-size: 11px;/> <label for="cb_cookieuser_navbar"> <input id="cb_cookieuser_navbar" type="checkbox" accesskey="c" tabindex="103" value="1" name="cookieuser" checked="checked"/> </label> <input type="submit" class="loginbutton" value="Login" tabindex="104" title="{vb:rawphrase enter_username_to_login_or_register}" accesskey="s" /> <input type="hidden" name="s" value="{vb:raw session.sessionhash}" /> <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" /> <input type="hidden" name="do" value="login" /> <input type="hidden" name="vb_login_md5password" /> <input type="hidden" name="vb_login_md5password_utf" /> </form> </div> <br /> <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> </td> </tr> </table> </div> </div> {vb:raw footer} </body> </html>
I use this mod to add CSS properties for pages: http://www.vbulletin.org/forum/showthread.php?t=228628
Finish.Code:.searchres { background: #fff; padding: 10px; margin: 0; }



LinkBack URL
About LinkBacks





Reply With Quote