• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Hướng dẫn thay tìm kiếm mặc định của vbb bằng tìm kiếm của google

Admin

Well-Known Member
Staff member
Administrator
Cách thực hiện:

1. Đăng ký tài khoản Google Custom Search:
- Vào đây để đăng ký: Google Custom Search - Site search and more

2. Tạo trang google.php với nội dung sau và upload lên thư mục gốc của diễn đàn (có thể tạo bằng Notepad, Notepad++, Dreamweaver...)

PHP:
 <?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());  

?>
4. Sửa đổi template navbar:

- Vào template navbar tìm:
HTML:
        <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="(is_browser('ie') AND !is_browser('ie', 7) AND  !is_browser('ie', 8))">gif<vb:else />png</vb:if>"  name="submit" onclick="document.getElementById('navbar_search').submit;"  tabindex="100"/></span></span>          </form>
- Thay bằng:

HTML:
<!-- Google Custom Search  -->  <form  action="http://www.domain.com/google.php" id="cse-search-box">   <input type="hidden" name="cx"  value="xxxxxxxxxxxxxxxxxxxxx:xxxxxxx-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>   <!-- /Google Custom Search  -->
Lưu ý:
+ Thay link đến file google.php của bạn vào.
+ Thay xxxxxxxxxxxxxxxxxxxxxxx-xxxx bằng Google Adsense code của bạn.
+ Nếu bị lỗi font thì thay ISO-8859-1 bằng UTF-8.
 

Facebook Comments

Similar threads

New posts New threads New resources

Back
Top