Hướng dẫn cách tạo module trượt 2 bên trong Joomla 1.5. Áp dụng thích hợp nhất
cho mod_banners làm quảng cáo tự động trượt 2 bên website. Tùy chỉnh code cho
phù hợp với website của bạn.
Chèn đoạn mã sau vào cuối file index.php trong
thư mục Joomla
template của bạn.
Ví dụ: /Joomla/templates/sieuhostvn/index.php.
Chèn
vào cuối trang trước khi đóng thẻ </body>
Mã HTML:
<div id="AdsRight">
<jdoc:include type="modules" name="floatright" />
</div>
<div id="AdsLeft">
<jdoc:include type="modules" name="floatleft" />
</div>
Mã Javascript:
<script type="text/javascript">Hiển thị quảng cáo trượt phải
function f_clientWidth() {
return f_filterResults (
window.innerWidth ? window.innerWidth : 0,
document.documentElement ? document.documentElement.clientWidth : 0,
document.body ? document.body.clientWidth : 0
);
}
function f_clientHeight() {
return f_filterResults (
window.innerHeight ? window.innerHeight : 0,
document.documentElement ? document.documentElement.clientHeight : 0,
document.body ? document.body.clientHeight : 0
);
}
function f_scrollLeft() {
return f_filterResults (
window.pageXOffset ? window.pageXOffset : 0,
document.documentElement ? document.documentElement.scrollLeft : 0,
document.body ? document.body.scrollLeft : 0
);
}
function f_scrollTop() {
return f_filterResults (
window.pageYOffset ? window.pageYOffset : 0,
document.documentElement ? document.documentElement.scrollTop : 0,
document.body ? document.body.scrollTop : 0
);
}
function f_filterResults(n_win, n_docel, n_body) {
var n_result = n_win ? n_win : 0;
if (n_docel && (!n_result || (n_result > n_docel)))
n_result = n_docel;
return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
</script>
Hiển thị quảng cáo trượt trái
<script type="text/javascript">
var positionFooter;
var positionRight = 0;
var widthAds = 110;
var heightAds = 200;
var div = document.getElementById('divPositionRightBannerFloat');
if(div!=null)
positionRight = div.offsetTop;
document.getElementById('AdsRight').style.display = "block";
var yy = 0;
var toptop=0;
var beforeTop = 0;
// Hien thi quang cao truot phai
function ShowAds()
{
yy = f_clientWidth() - widthAds - 24;//padding left
toptop = (f_scrollTop() - beforeTop)/8;
beforeTop = toptop + beforeTop + 3;
if(beforeTop < 5)
document.getElementById('AdsRight').style.top = f_scrollTop() + 'px';
else
document.getElementById('AdsRight').style.top = beforeTop + 'px';
beforeTop = parseInt(document.getElementById('AdsRight').style.top.substring(0,document.getElementById('AdsRight').style.top.length - 2));
document.getElementById('AdsRight').style.left = yy + 'px';
document.getElementById('AdsRight').style.display = "block";
if(beforeTop < positionRight + heightAds)
document.getElementById('AdsRight').style.display = "none";
var divFooter = document.getElementById('divPositionFloatBannerFooter');
if(divFooter!=null)
positionFooter = divFooter.offsetTop;
if(beforeTop > positionFooter + heightAds)
document.getElementById('AdsRight').style.display = "none";
setTimeout('ShowAds()', 50);
}
ShowAds();
</script>
<script type="text/javascript">
// Hien thi quang cao truot trai
function ShowAds2()
{
yy = f_clientWidth() - widthAds - 24;//padding left
toptop = (f_scrollTop() - beforeTop)/8;
beforeTop = toptop + beforeTop + 3;
if(beforeTop < 5)
document.getElementById('AdsLeft').style.top = f_scrollTop() + 'px';
else
document.getElementById('AdsLeft').style.top = beforeTop + 'px';
beforeTop = parseInt(document.getElementById('AdsLeft').style.top.substring(0,document.getElementById('AdsLeft').style.top.length - 2));
document.getElementById('AdsLeft').style.right = yy + 'px';
document.getElementById('AdsLeft').style.display = "block";
if(beforeTop < positionRight + heightAds)
document.getElementById('AdsLeft').style.display = "none";
setTimeout('ShowAds2()', 50);
}
// Hien thi quang cao truot trai + phai
ShowAds2();
</script>
Hoặc tải file advertisement.js về và chèn đoạn mã sau
<script type="text/javascript" src="/cntt/js/advertisement.js"></script>Mã CSS chèn vào file template CSS hoặc chèn vào head:
#AdsRight{
z-index: 9999;
position: absolute;
width: 110px;
height: 200px;
display: none;
}
#AdsLeft{
z-index: 9999;
position: absolute;
width: 110px;
height: 200px;
display: none;
}Truy
cập Back End >> Quản lý mô đun.Chọn module cần trượt gán vào vị trí floatleft hoặc floatright.
Tin mới hơn:
- 26/12/2010 05:46 - Cách cài đặt ngôn ngữ tiếng Việt cho Joomla! 1.5.x
- 06/10/2010 16:02 - Gỡ bỏ bản quyền Joomla SEO powered by JoomSEF trong Joomsef 3.7.4
Tin cũ hơn:
- 06/10/2010 15:53 - Tạo Module Hello World cho Joomla 1.5
- 06/10/2010 15:50 - Chống tấn công SQL injection
- 06/10/2010 15:46 - Vấn đề bảo mật Joomla chống backdoor từ những template và extension lậu
- 24/02/2010 20:05 - Cách tạo diễn đàn với Simple Machines Forum
- 24/02/2010 20:04 - CHMOD File và Folder trên Web Server
- 24/02/2010 20:03 - Cách bảo mật cho Website Joomla!
- 24/02/2010 19:56 - Cách tích hợp bộ gõ tiếng Việt vào Joomla! và SMF
- 24/02/2010 19:53 - Cách tối ưu hóa cho Website Joomla!
- 24/02/2010 19:50 - Cách cài đặt các bản nâng cấp và sửa lỗi cho Joomla!
- 24/02/2010 19:02 - Cách chuyển đổi Template từ Joomla! 1.0.x sang 1.5.x
- 24/02/2010 18:31 - Cách chuyển đổi Joomla! 1.0.x sang Joomla! 1.5.x
- 24/02/2010 17:21 - Cơ bản về Template trong Joomla! 1.0.x
- 24/02/2010 17:16 - Cơ bản về Template của Joomla! 1.5.x
- 24/02/2010 17:11 - Cách tạo các vị trí Module trong Joomla! Template
- 23/02/2010 20:16 - Cách làm trang Web bán hàng với Joomla! và VirtueMart
- 23/02/2010 20:15 - Cấu trúc Template joomla! 1.5.x
- 23/02/2010 20:10 - Xem các vị trí trong joomla
- 23/02/2010 20:08 - Upload Joomla 1.5 lên server
- 23/02/2010 20:07 - Cấu hình Joomla trên Hosting
- 23/02/2010 19:54 - Hướng dẫn cài đặt Wamp
- 23/02/2010 19:29 - Các bước cài đặt Joomla
- 23/02/2010 19:17 - Cài đặt template cho Joomla! 1.5
- 23/02/2010 19:14 - Các khái niệm Section, Category và Content là gì?
- 23/02/2010 19:12 - Khái niệm Front-end và Back-end
- 23/02/2010 19:10 - Module là gì?
- 23/02/2010 18:58 - 10 sự thay đổi trong Joomla 1.5
- 23/02/2010 18:54 - Các phiên bản của Joomla!
- 23/02/2010 18:53 - Vòng đời phát triển joomla
- 23/02/2010 18:51 - Joomla là gì? Một vài định nghĩa về Joomla
- 23/02/2010 18:45 - Cách trình bày trang Homepage (Frontpage)
Kiến Thức Thiết Kế Web 


