Add a random quote block to the sidebar - Thêm một block trích dẫn ngẫu nhiên vào sidebar 1.0

PVS

Super Moderator
Thành viên BQT
Code hoặc hướng dẫn này được sử dụng trên phiên bản Xenforo cũ đã quá hạn sử dụng. Bạn hãy click để tìm bản mới hơn
Add a random quote block to the sidebar - Thêm một block trích dẫn ngẫu nhiên vào sidebar 1.0

Bước 1: Giải nén và tải lên các tập tin đính kèm vào thư mục /data của bạn để nó cho thấy là /data/RandomQuote
Bước 2: Dán đoạn code sau trong PAGECONTAINER trước </head>
Mã:
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function($) {
    $.get('./data/RandomQuote/quotes.txt', function(data) {
        var quotes = data.split("\@");
        var idx = Math.floor(quotes.length * Math.random());
        $('.quotes').html(quotes[idx]);
    });
});
</script>

Bước 3: Thêm vào EXTRA.css
Mã:
.bqstart {
    float: left;
    font-size: 300%;
    margin-right: 5px;
    height: 15px;
}

.bqend {
    float: right;
    font-size: 300%;
    margin-top: -20px;
    height: 15px;
}
  .bq {
    font-family: "WCManoNegraBtaRegular", Arial, sans-serif;
    font-size: 180%;
    margin-right: 15px;
}
@font-face {
    font-family: 'WCManoNegraBtaRegular';
    src: url('./data/RandomQuote/WCManoNegraBta-webfont.eot');
    src: local('☺'), url('./data/RandomQuote/WCManoNegraBta-webfont.woff') format('woff'), url('./data/RandomQuote/WCManoNegraBta-webfont.ttf') format('truetype'), url('./data/RandomQuote/WCManoNegraBta-webfont.svg#webfonte6F4DwaZ') format('svg');
}

Bước 4: Tạo một template mới được gọi là random_quote, và thêm vào đoạn code sau:
Mã:
<div class="secondaryContent">
<div class="bqstart">&#8220;</div>
<div class="quotes bq" style="padding-top: 10px; padding-right: 5px;"></div>
<div class="bqend">&#8221;</div>
</div>

Nếu bạn muốn có một tiêu đề trên block thì sử dụng mã này để thay thế
Mã:
<div class="section">
<div class="secondaryContent">
<h3>Random Quote</h3>
<div class="bqstart">&#8220;</div>
<div class="quotes bq" style="padding-top: 10px; padding-right: 5px;"></div>
<div class="bqend">&#8221;</div>
</div>
</div>

Bước 5: Chỉnh sửa forum_list và thêm <xen:include template="random_quote" /> vào trước </xen:sidebar> hoặc bất cứ nơi nào bạn muốn.

Thêm trích dẫn mới:
Nếu bạn muốn thêm trích dẫn mới, chỉnh sửa tập tin /data/RandomQuote/quotes.txt
Thêm mỗi quote mới trên một dòng riêng biệt như sau:

It's a recession when your neighbor loses his job; it's a depression when you lose yours. - Harry S Truman@
Any man who afflicts the human race with ideas must be prepared to see them misunderstood. - H. L. Mencken@
You must lose a fly to catch a trout. - George Herbert


Tất cả các mục phải được chấm dứt với một @ trừ mục cuối cùng.

Kết quả:

quote.PNG
quote2.PNG

Chúc các bạn thành công.


Nguồn: xenforo.com​
 
Back
Top