POST TIME:2020-03-29 11:37
我們知道織夢模板有個(gè)小說模塊,但是一直以來卻不知道如何在首頁進(jìn)行調(diào)用,查詢好多網(wǎng)站都沒有詳細(xì)的解答,恰巧今天在一個(gè)論壇里看到一位朋友給出了相應(yīng)的調(diào)用代碼,現(xiàn)收藏下,以便以后使用。
代碼片段:
<div id="demo" style="OVERFLOW: hidden; WIDTH: 100%; COLOR: #ffffff">
<table width="120" cellspacing="0" cellpadding="0" align="center" border="0" cellspace="0">
<tbody>
<tr>
<td id="demo1" valign="top">
<table width="110">
<tr>{dede:sql sql="Select bid,bookname,author,pubdate,body,litpic From dede_story_books order by bid desc limit 0,8"}
<td align="center"><a href="/book/book.php?bid=[field:bid/]" target="_blank"><img src="[field:litpic/]" alt="[field:bookname/]" border="0"/ width="115" height="130"></a>
<li><a><strong>作 者:</strong>[field:author /]</a></li>
<li><a href="/book/book.php?bid=[field:bid/]" target="_blank">[field:bookname/]</a></li> </td>
{/dede:sql}
</tr>
</table>
</td>
<td width="0" valign="top" id="demo2"></td>
</tr>
</tbody>
</table>
</div>
<script>
var speed3=30//速度數(shù)值越大速度越慢
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed3)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed3)}
</script>
以上代碼可以直接插入到首頁需要安放小說模塊調(diào)用的地方,我的站將這部分安放在“圖文資訊”欄目下方了。完整代碼是在“圖文資訊”下方插入
代碼片段:
<div class="picnews">
<dl class="tbox light">
<dt class='light'><strong>圖書連載</strong></dt>
<dd class='light'>
<div id="demo" style="OVERFLOW: hidden; WIDTH: 100%; COLOR: #ffffff">
<table width="120" cellspacing="0" cellpadding="0" align="center" border="0" cellspace="0">
<tbody>
<tr>
<td id="demo1" valign="top">
<table width="110">
<tr>{dede:sql sql="Select bid,bookname,author,pubdate,body,litpic From dede_story_books order by bid desc limit 0,8"}
<td align="center"><a href="/book/book.php?bid=[field:bid/]" target="_blank"><img src="[field:litpic/]" alt="[field:bookname/]" border="0"/ width="115" height="130"></a>
<li><a><strong>作 者:</strong>[field:author /]</a></li>
<li><a href="/book/book.php?bid=[field:bid/]" target="_blank">[field:bookname/]</a></li> </td>
{/dede:sql}
</tr>
</table>
</td>
<td width="0" valign="top" id="demo2"></td>
</tr>
</tbody>
</table>
</div>
<script>
var speed3=30//速度數(shù)值越大速度越慢
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed3)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed3)}
</script>
</dd>
</dl>
</div>
提示:當(dāng)然大家可以根據(jù)自己站的特點(diǎn),修改相關(guān)代碼。