Page 2 of 2 FirstFirst 1 2
Results 16 to 18 of 18

Making vBulletin search more prominent

This is a discussion on Making vBulletin search more prominent within the General Discussion forums, part of the vBulletin SEO Discussion category; I have been worked on it and on my vb 4.0.1 community seem to work without problems, i post here ...

  1. #16
    Senior Member
    Real Name
    Alex
    Join Date
    Mar 2007
    Location
    Italy
    Posts
    508
    Liked
    0 times
    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


    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>
    The part in blue needs to be a custom made page. This acts as the 'wrapper' for the search results.

    It's a simple php script that does nothing more than call the 'skin' and a new custom search template.


    guestsearch.php

    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());
    
    ?>
    Finally, add the new template:

    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


    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>
    just add to the final custom CSS block in CSS Templates: (and change colors to match your skin if necessary)

    I use this mod to add CSS properties for pages: http://www.vbulletin.org/forum/showthread.php?t=228628

    Code:
    .searchres { 
    background: #fff;
    padding: 10px;
    margin: 0;
    }
    Finish.

  2. #17
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,782
    Liked
    648 times
    Blog Entries
    2
    Thank you for this, Alex. Great update!
    Brian Cummiskey / Crawlability Inc.
    vBSEO 3.6.0 GOLD Released!
    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  3. #18
    Senior Member
    Real Name
    Michael Biddle
    Join Date
    Jan 2007
    Location
    Southern California
    Posts
    7,097
    Liked
    4 times
    Thanks Alex!
    The Forum Hosting - Forum Hosting from the Forum Experts

Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Google Analytics "Site Search" with vBulletin search
    By PeterNRG in forum Off-Topic & Chit Chat
    Replies: 43
    Last Post: 11-28-2010, 01:45 AM
  2. Replies: 2
    Last Post: 10-09-2008, 02:14 PM
  3. Replies: 6
    Last Post: 03-28-2006, 01:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •