在jtbc中在新闻列表页面调用摘要的方法,前阵子和一网友讨论的,发份在这里,仅作备忘。其中方法二未亲自实验,不过另一网友已实验通过。
方法一:
打开article\common\incfiles\module_config.asp 找到Function jtbc_cms_module_list()函数定义,再找到
For jcuti = 1 To npagesize
If Not rs.EOF Then
tmptstr = Replace(tmpastr, "{$topic}", icoloration(htmlencode(get_str(rs(cfname("topic")))), "b=" & get_num(rs(cfname("topic_b")), 0) & ";color=" & get_safecode(rs(cfname("topic_color")))))
tmptstr = Replace(tmptstr, "{$time}", get_date(rs(cfname("time"))))
tmptstr = Replace(tmptstr, "{$count}", get_num(rs(cfname("count")), 0))
tmptstr = Replace(tmptstr, "{$good}", get_num(rs(cfname("good")), 0))
tmptstr = Replace(tmptstr, "{$id}", get_num(rs(nidfield), 0))
rs.movenext
tmprstr = tmprstr & tmptstr
End If
Next
类似上面的循环,这个的作用是对于新闻列表循环中的每一条记录,进行替换{$}这些为数据库中的值。那么添加
tmptstr = Replace(tmptstr, “{$summary}”, left(htmlencode(get_str(rs(cfname(“content”)))),20))
对数据库中content的内容读取后,取20位。再替换{$summary}为新内容。
在前台模板处需要显示摘要的地方加上{$summary}。为新闻列表的那么循环里面。
方法二:
到调用模板节点,点下边“新增一个新节点”,命名如5,将第一个节点内容完全复制到5内容框中。找到
这样一段代码
{$$}
<td height=”20″><a href=”{$=curl(“{$baseurl}”, iurl(‘detail’, {$id}, {$urltype}, ‘folder={$createfolder};filetype={$createfiletype};time={$time}’))}” target=”_self”>{$topic}</a></td>{$$}
在</</td>{$$}前面加上一句代码<br />{$=ileft(rsvle(‘content’), 100)},加此句代码就调用的内容
摘要,100表示从文章中截取的文字数,<br />表示回车换行,否则,内容与标题会出现在一行中。
这样,调用模板设置好了。
在首页或者栏目页,需要调用重要新联标题和摘要的地方,加上一句代码{$=itransfer(‘top’, ’5′, ‘topx=5;tnum=30;genre=article’)};