DEDE 仿站模板简谈

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;
         background-color: #FFF;}
.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}

 

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">

 

 

 

 

 

 

posted @ 2014-03-08 23:23  神煌  阅读(411)  评论(0编辑  收藏  举报