Hướng dẫn tạo bài viết liên quan bằng Google Custom Search Engine
Như các bạn đã biết là sử dụng bài viết liên quan sẽ làm tăng thời gian ở lại trang hơn cho khách. Trên mạng google có chia sẻ nhiều cách tạo bài viết liên quan khác nhau. Nhưng ở đây mình chỉ nhắc đến forumotion và blogger :)
Bước 1: Các bạn truy cập vào link sau
Code:
https://cse.google.com
Bước 2: Tạo Công cụ tìm kiếm tùy chỉnh
Khí đó nó sẽ hiện ra một cái bảng như sau
Bước 3 : Click tạo và nhận mã :)
Khi đó Google Custom Search Engine sẽ cho bạn 1 đoạn code tương tự như sau
Code:
<script>
(function() {
var cx = '001420502274921617850:81ejldthzmi';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
001420502274921617850:81ejldthzmi là dãy số của web hotrofm.net. của các bạn sẽ khác.
Code bài viết liên quan bằng Google Custom Search Engine dành cho forumotion
Code:
<div class="co-the-quan-tam">
<h3 class="heading">Có Thể Bạn Quan Tâm</h3>
<div id='cse-search-form' style='width: 100%;height:300px;overflow-y: scroll;'>Đang tải...</div>
<script src='http://www.google.com/jsapi' type='text/javascript'></script>
<script type='text/javascript'>
google.load('search', '1', {language: 'vi'});
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl("001420502274921617850:81ejldthzmi");
customSearchControl.setResultSetSize(google.search .Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse-search-form');
customSearchControl.execute("~{FORUM_NAME} + ~{PAGE_TITLE}");
}, true);
</script>
<style>
.co-the-quan-tam{height:346px;margin-bottom:20px;border:1px solid #e6e6e6}
.co-the-quan-tam h3.heading{font-size:16px;color:#FFF;background-color:#3a5795;padding:8px;margin-bottom:3px;text-transform:uppercase!important}
.co-the-quan-tam table td,table th{border-width:0;padding:5px 10px}
.co-the-quan-tam .gsc-webResult .gsc-result{padding:0!important}
.co-the-quan-tam .gsc-cursor{width:100%;text-align:center;float:left;font-size:20px;margin-top:15px}
.co-the-quan-tam .gs-result .gs-title,.co-the-quan-tam .gs-result .gs-title *{text-decoration:none!important;color:#FF9800!important}
.co-the-quan-tam .gs-result .gs-title a{text-decoration:none!important;color:#f6a812!important}
.co-the-quan-tam .gs-result a.gs-visibleUrl,.co-the-quan-tam .gs-result .gs-visibleUrl{font-weight:700}
.co-the-quan-tam .gs-bidi-start-align.gs-snippet{line-height:20px;margin:5px 0 0}
.co-the-quan-tam .gsc-results.gsc-webResult{width:100%}
.co-the-quan-tam .gsc-search-box,.co-the-quan-tam .gsc-above-wrapper-area,.co-the-quan-tam .gsc-resultsHeader,.co-the-quan-tam .gcsc-branding{display:none}
.co-the-quan-tam .gsc-thumbnail, .gs-spelling, .gsc-url-bottom {display: none;}
</style>
</div>
Nhớ thay 001420502274921617850:81ejldthzmi thành số của bạn
Code bài viết liên quan bằng Google Custom Search Engine dành cho blogger
Code:
<div class="co-the-quan-tam">
<h3 class="heading">Có Thể Bạn Quan Tâm</h3>
<div id='cse-search-form' style='width: 100%;height:300px;overflow-y: scroll;'>Đang tải...</div>
<script src='http://www.google.com/jsapi' type='text/javascript'></script>
<script type='text/javascript'>
google.load('search', '1', {language: 'vi'});
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl("001420502274921617850:81ejldthzmi");
customSearchControl.setResultSetSize(google.search .Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse-search-form');
customSearchControl.execute("~<data:blog.pageName/> + ~<data:blog.title/>");
}, true);
</script>
<style>
.co-the-quan-tam{height:346px;margin-bottom:20px;border:1px solid #e6e6e6}
.co-the-quan-tam h3.heading{font-size:16px;color:#FFF;background-color:#3a5795;padding:8px;margin-bottom:3px;text-transform:uppercase!important}
.co-the-quan-tam table td,table th{border-width:0;padding:5px 10px}
.co-the-quan-tam .gsc-webResult .gsc-result{padding:0!important}
.co-the-quan-tam .gsc-cursor{width:100%;text-align:center;float:left;font-size:20px;margin-top:15px}
.co-the-quan-tam .gs-result .gs-title,.co-the-quan-tam .gs-result .gs-title *{text-decoration:none!important;color:#FF9800!important}
.co-the-quan-tam .gs-result .gs-title a{text-decoration:none!important;color:#f6a812!important}
.co-the-quan-tam .gs-result a.gs-visibleUrl,.co-the-quan-tam .gs-result .gs-visibleUrl{font-weight:700}
.co-the-quan-tam .gs-bidi-start-align.gs-snippet{line-height:20px;margin:5px 0 0}
.co-the-quan-tam .gsc-results.gsc-webResult{width:100%}
.co-the-quan-tam .gsc-search-box,.co-the-quan-tam .gsc-above-wrapper-area,.co-the-quan-tam .gsc-resultsHeader,.co-the-quan-tam .gcsc-branding{display:none}
.co-the-quan-tam .gsc-thumbnail, .gs-spelling, .gsc-url-bottom {display: none;}
</style>
</div>
Nhớ thay 001420502274921617850:81ejldthzmi thành số của bạn
Tags: #code #forumotion #blogger