使用織夢系統最經常是為了仿站,那么模板應該怎么改?
這里主要談談關於比較常用的幾個模板頁
網站主頁、列表頁、內容頁、欄目的調用
1.主頁模板
常用組合方法:index.htm + head.htm + footer.htm
嵌套語句:{dede:include filename="head.htm"/}
head.htm :網站頭部(頂部+導航欄),所以也可繼續拆分。一般頂部內容為從body后開始至導航欄。
導航欄 (自動獲取欄目信息)
<div id="navtabs">
<a href="{dede:global.cfg_cmsurl/}/" class="current">首頁</a>
{dede:channel type='top' row='10' currentstyle="<a href='~typelink~' >~typename~</a>"}
<a href='[field:typeurl/]' >[field:typename/]</a>
{/dede:channel}
</div>
二級欄目:直接指定所有二級鏈接,原網站都有js控制,直接拿來用就行
footer.htm:網站底部,包含版權信息,具體看實際的布局,大部分網站的友情鏈接作為獨立模塊在底部,包含進來更方便。
首頁調用文章列表的方法,通過標簽進行嵌套就行
示例:
{dede:arclist row='9' typeid='2' infolen='300'}
<li><div class="ntitle f_l">
·<a href="[field:arcurl/]" class="hei" title="[field:fulltitle/]" target="_blank">
[field:fulltitle function='cn_substr(@me,80)'/]
</a></div>
<div class="ndate f_r"><a href="[field:arcurl/]" class="hui" target="_blank">[field:pubdate function="MyDate('Y-m-d',@me)"/]</a>
</div></li>
{/dede:arclist}
效果:

dede arclist里field:body的調用方法:
用arclist調用附加表字段,要獲取附加表內容,必須指定兩個條件:1、指定channelid 屬性;2、指定要獲得的字段addfields='字段1,字段2'。
{dede:arclist row='5' channelid='1' addfields='body' typeid='1' orderby='rand'}
控制body的長度:[field:body function="cn_substr(html2text(@me),120)"/]
{/dede:arclist}
縮略標題
[field:title function='(strlen("@me")>60?cn_substr("@me",60)."…":"@me")'/]
2.文章列表頁
欄目名稱:{dede:field name='typename' /}
獲取頂級欄目下的所有欄目:
{dede:channel type='son' typeid='1'}
<li>
<a href="[field:typelink/]" title="[field:typename/]" style="color:#003366;background-position:-46px -78px;">[field:typename/]</a>
</li>
{/dede:channel}
獲取欄目下的文章分頁列表
{dede:list pagesize='5'}
<li>
<div class='fleft'>
<h1>
<a href="[field:arcurl/]" title='[field:title/]'>·[field:title/]</a>
<span class='addtime'>[field:pubdate function='strftime("%Y-%m-%d",@me)'/]</span> <img src="/images/public/hot06.gif">
</h1>
<p>
[field:body function='cn_substr(html2text(@me),350)'/]...
</p>
</div>
<a href="[field:arcurl/]" title='[field:title/]' class='a'>查看詳情 >>></a><div class='clearfix'>
</div>
</li>
{/dede:list}
分頁
<style type='text/css'>
.pagelist{padding-top: 10px;padding-bottom: 10px; text-align: center;}
.pagelist li{ display: inline; line-height: 22px;}
.pagelist li a{margin-right: 5px;padding-right: 5px;padding-left: 5px;padding-top: 3px;padding-bottom: 3px;border: 1px solid #CCC;
}
.thisclass {font-weight: bold;color: #C00;}
</style>
<ul class="pagelist"> {dede:pagelist listitem="info,index,end,pre,next,pageno" listsize="5"/} </ul>
效果:
3.文章內容頁
文章標題:{dede:field.title/}
網站名稱:{dede:global.cfg_webname/}
來源:{dede:field name='source'/}
標簽:
<div class="singleout">
<div class="singlein">
<div class="news_show">
<h1 style="color:#003366;">{dede:field.title/}</h1>
<h2 style="border-top:#663300 1px dashed;color:#666666;">
發布者:{dede:field.writer/}
發布時間:{dede:field.pubdate function="MyDate('Y-m-d',@me)"/}
點擊:<script src="{dede:field name='phpurl'/}/count.php?view=yes&aid={dede:field name='id'/}&mid={dede:field name='mid'/}" type='text/javascript' language="javascript"></script>次
</h2>
<div class="showcontent">
{dede:field.body/}
</div>
</div>
</div>
</div>
上一篇下一篇
<ul>
<li>{dede:prenext get='pre'/}</li>
<li>{dede:prenext get='next'/}</li>
</ul>
直接調用上一篇地址和下一篇地址的代碼如下:
上一篇地址
{dede:prenext get='pro' runphp="yes"}preg_match_all('/<a.*?(?: |\\t|\\r|\\n)?href=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>(.+?)<\/a.*?>/sim', @me, $strResult, PREG_PATTERN_ORDER);@me=$strResult[1][0];{/dede:prenext}
下一篇地址
{dede:prenext get='next' runphp="yes"}preg_match_all('/<a.*?(?: |\\t|\\r|\\n)?href=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>(.+?)<\/a.*?>/sim', @me, $strResult, PREG_PATTERN_ORDER);@me=$strResult[1][0];{/dede:prenext}
內容分頁
1.分頁標簽:“{dede:pagebreak/}”,一般是添加在“{dede:field.body/}”標簽之后
2.進入系統—系統基本參數—性能選項,選擇第二項:是否開啟長文章自動分頁,選擇是即可。
3.發布文章的時候,需要在哪里設置分頁,就在“編輯器”里面,選擇以下:#P#, 在內容頁自動插入文本 “#p#副標題#e#”
4.修改分頁樣式
修改文件位置:include/arc.archives.class.php找到靜態頁面分頁方法GetPagebreak,即可修改,
默認生成代碼模塊如:<li><a>共1頁:</a><li> <li><a>上一頁</a><li> <li><a>1</a><li> <li><a>下一頁</a><li>
4.欄目內容頁
使用場景:欄目只有一個頁面
使用方法:在欄目模板中用{dede:field.content/}調用
5.圖片調用方法
1.<a href='[field:arcurl /]'><img src='[field:litpic/]' border='0' width='' height=''></a> 2.[field:imglink /] 3.<a href='[field:arcurl /]'> [field:image/]</a>
說明:
[field:imglink /]與<a href='[field:arcurl /]'>[field:image/]</a> 是完全等價的
在文章內容頁加入圖片標簽:<img src="{dede:field name="litpic"/}" border="0">

