Home  >  Article  >  CMS Tutorial  >  How to use the dedecms tag

How to use the dedecms tag

angryTom
angryTomOriginal
2019-07-29 14:08:046241browse

There are three ways to use: 1. "{dede: tag name attribute = 'value'}"; 2. "{dede: tag name attribute = 'value'} {/dede: tag name}"; 3. "{dede:mark name attribute='value'}custom template (InnerText){/dede:mark name}".

How to use the dedecms tag

#It is very meaningful to understand the knowledge of Dreamweaver template engine. The template engine is a template parser that uses XML namespaces. The biggest advantage of using the Dreamweaver parser to parse templates is that you can easily specify the attributes of the tag. It feels like using HTML, making the template code very intuitive and flexible. The new version of the DreamWeaver template engine can not only parse the template but also analyze the wrong tags in the template.

1. The code styles of the Dreamweaver template engine have the following forms:

  •  {dede: tag name Attribute='value'/}

  •  {dede:mark name attribute='value'}{/dede:mark name}

  •  {dede:tag name attribute='value'}Custom style template (InnerText){/dede:tag name}

Tips:

If you use a tag with an underlying template, you must strictly use the {dede: tag name attribute ='value'}{/dede:mark name} This format, otherwise an error will be reported.

[Arclist tag]

This tag is the most commonly used tag in DedeCms, also called the free list tag, among which hotart, Coolart, likeart, artlist, imglist, imginfolist, specart, and autolist are all alias tags extended by the different attributes defined by this tag.

Function description: Get the specified document list

Scope of application: Cover template, list template, document template

Basic syntax:

{dede:arclist typeid='' row='' col='' titlelen='' infolen='' imgwidth='' imgheight='' listtype='' orderby='' keyword=''}

Underlying template (InnerText){/dede:arclist}

Attribute description:

 [1] typeid='' represents the column ID, which generally does not need to be specified in list templates and file templates. In the cover template, "," is allowed to represent multiple columns separately;

 [2] row='' means the total number of document lists returned;

 [3] col='' means how many columns to display (default is single column);

 [4] titlelen='' means the title length

 [5] infolen='' represents the content introduction length;

 [6] imgwidth='' represents the thumbnail width;

 [7] imgheight='' represents Thumbnail height;

 [8] type='' indicates the file type, in which a null value, this attribute is not used, or type='all' is a normal document

 § type='commend ', indicates recommended documents, equivalent to {dede:coolart}{/dede:coolart}

 § type='image', indicates documents that must contain thumbnail images, equivalent to {dede:imglist} {/dede:imglist}、{dede:imginfolist}  {/dede:imginfolist}

 § When type='spec', it indicates the topic, which is equivalent to the mark {dede:specart}{/dede:specart}

The above attribute values ​​can be used in combination, such as: type='commend image' indicates recommended image documents

[9] orderby='' indicates the sorting method, the default value is senddate, arranged by release time .

  § orderby='hot' or orderby='click' means sorting by the number of clicks

  § orderby='pubdate' means sorting by publication time (that is, the time value that the front desk allows to change)

  § orderby='sortrank' Sort by the new sorting level of the article (use this attribute if you want to use pinned articles)

  § orderby='id' Sort by article ID

  § orderby='postnum' Sort by the number of article comments

  § orderby='rand' Randomly obtain a list of documents with specified conditions

 [10] orderway='' The value is desc or asc , specifies whether the sorting method is descending order or forward sorting. The default is descending order.

 [11] keyword='' represents a list of documents containing specified keywords, multiple keywords are separated by ","

 [12] channelid='' represents a specific channel model ID , built-in channels: topic (-1), article (1), photo gallery (2), Flash (4), software (3)

  [13] limit='起始,结束' 表示限定的记录范围,row属性必须等于"结束 - 起始",mysql的limit语句是由0起始的,如 “limit 0,5”表示的是取前五笔记录,“limit 5,5”表示由第五笔记录起,取下五笔记录,使用了本属性后,row属性将无效。

  [14] att='数值' 表示自定义属性值

  [15] subday='天数' 表示在多少天以内的文档,通常用于获取指定天数的热门文档、推荐文档、热门评论文档等

  [16] partsort='排列位数' 表示自动获得父栏目的所有子数中排列在第几位的栏目ID,标记为 {dede:autolist}{/dede:autolist} 时,使用本属性才有效。    

底层模板字段:

  ID(同 id),title,iscommend,color,typeid,ismake,description(同 info),writer,shorttitle,memberid

  pubdate,senddate,arcrank,click,litpic(同 picname),typedir,typename,

  arcurl(同 filename),typeurl,stime(pubdate 的"0000-00-00"格式),

  textlink,typelink,imglink,image 

其中:

  textlink = 34453e2ac4fcbd442412e399678544cbtitle5db79b134e9f6b82c0b36e0489ee08ed

  typelink = 61e94dc331502cdd22b5b4f7595ae405typename5db79b134e9f6b82c0b36e0489ee08ed

  imglink = 34453e2ac4fcbd442412e399678544cb075d54bd63f566920180777d95fb87bf5db79b134e9f6b82c0b36e0489ee08ed

  image = 075d54bd63f566920180777d95fb87bf 
字段调用方法:[field:varname/]

如:

  {dede:arclist infolen='100'}
  [field:textlink/]
  <br>
  [field:info/]
  <br>
  {/dede:arclist}

注:底层模板里的Field实现也是织梦标记的一种形式,因此支持使用PHP语法,Function扩展等功能

如: 给当天发布的内容加上 (new) 标志

[field:senddate runphp=&#39;yes&#39;] 
$ntime = time();
$oneday = 3600 * 24;
if(($ntime - @me)<$oneday) @me = "<font color=&#39;red&#39;>(new)</font>";
else @me = "";
[/field:senddate]

【Field 标记】

功能说明:用于获取特定栏目或档桉的字段值及常用的环境变量值

适用范围:封面模板、列表模板、文档模板

(1)基本语法

{dede:field name=&#39;字段名&#39;/}

(2) 系统分配的field
  板块模板:phpurl,indexurl,indexname,templeturl,memberurl,powerby,webname,specurl 

  列表模板:position,title,phpurl,templeturl,memberurl,powerby,indexurl,indexname,specurl,栏目表dede_arctype的所有字段

  其中 position 为 “栏目一 > 栏目二” 这样形式的链接,title则为这种形式的标题 

  文档模板:position,phpurl,templeturl,memberurl,powerby,indexurl,indexname,specurl,id(同 ID,aid)
(3) 文档所有内容字段

档案dede_archives表 和 附加表的所有字段。 

【Channel 标记】 

  功能说明:用于获取栏目列表 

  适用范围:封面模板、列表模板、文档模板 

(1)基本语法

{dede:channel row=&#39;&#39; type=&#39;&#39;}

  自定义样式模板(InnerText)

    {/dede:channel} 
(2)属性 
  [1] row='数字' 表示获取记录的条数(通用在某级栏目太多的时候使用,默认是 8) 

  [2] type = top,sun/son,self 

    type='top' 表示顶级栏目

    type='son' 或 'sun' 表示下级栏目

    type='self' 表示同级栏目 

   其中后两个属性必须在列表模板中使用。 

  (3)底层模板变量 

    ID,typename,typedir,typelink(仅表示栏目的网址) 
例:

{dede:channel type=&#39;top&#39;}
<a href=&#39;[field:typelink /]&#39;>[field:typename/]</a> 
{/dede:channel}

注:在没有指定typeid的情况下,type标记与模板的环境有关,如,模板生成到栏目一,那么type='son'就表示栏目一的所有子类

【Type 标记】别名 onetype 

功能说明:表示指定的单个栏目的链接

适用范围:封面模板、列表模板、文档模板

(1)语法

 {dede:type typeid=&#39;&#39;}{/dede:type}

(2)属性 

  typeid='栏目ID'

(3)底层模板变量 

  typename,typelink(仅表示栏目的网址)

【Autochannel 标记】

功能说明:表示指定排序位置的单个栏目的链接

适用范围:封面模板、列表模板、文档模板

(1)语法

 {dede:autochannel partsort=&#39;&#39;}{/dede:autochannel}

(2)属性

 partsort='栏目所在的排序位置'

(3)底层模板变量 

typename,typelink(仅表示栏目的网址)

【Mytag 标记】 

功能说明:用于获取自定义宏标记的内容 

适用范围:封面模板、列表模板、文档模板 

(1)基本语法 

{dede:mytag typeid=&#39;&#39; name=&#39;&#39; ismake=&#39;&#39;/}

(2)属性 

  [1] typeid = '数字' 表示栏目ID,默认为 0,在没有设定的栏目没有定义这个名称的标记,会按如下搜索方式来搜索“先向上查找父栏目 -> 通用标记(typeid=0)的同名标记”。 

  [2] name = '' 标记名称。 

  [3] ismake = yes|no 默认为 no 表示mytag里的内容不包含其它封面模板的标记,yes则表示标记内容含有其它封面模板标记。 

【Vote 标记】 

功能说明:用于获取一组投票表单 

适用范围:封面模板 

(1) 基本语法

{dede:vote id=&#39;投票ID&#39; lineheight=&#39;22&#39;
tablewidth=&#39;100%&#39; titlebgcolor=&#39;#EDEDE2&#39;
titlebackground=&#39;&#39; tablebgcolor=&#39;#FFFFFF&#39;}
{/dede:vote}

注:本标记直接生成投票的HTML表单,为了让你更方便修改其样式,建议在后台->投票管理的地方直接复制生成的HTML代码来使用。

【Flink 标记】,等同 friendlink 

功能说明:用于获取友情链接 

适用范围:封面模板 

(1)基本语法 

{dede:flink type=&#39;&#39; row=&#39;&#39; col=&#39;&#39; titlelen=&#39;&#39; tablestyle=&#39;&#39;}{/dede:flink}

(2)属性

  [1]type:链接类型,值:

   a. textall 全部用文字显示

   b. textimage 文字和图得混合排列

   c. text 仅显示不带Logo的链接

   d. image 仅显示带Logo的链接

-------------------------------------

  [2]row:显示多少行,默认为4行

  [3]col:显示多少列,默认为6列

  [4]titlelen:站点文字的长度

  [5]tablestyle: 表示 6aee7a10b0c3b50251b87c9490a839cf 

【Mynews 标记】 

功能说明:用于获取站内新闻 

适用范围:封面模板 

(1) 基本语法 

{dede:mynews row=&#39;条数&#39; titlelen=&#39;标题长度&#39;}Innertext{/dede:mynews}

(2)属性

  [1] row 新闻条数

  [2] titlelen 标题长度

  (3)底层模板变量

[field:title/]、[field:writer/]、
[field:senddate function="strftime(&#39;%y-%m-%d %H:%M&#39;,@me)"/](时间)、[field:body/]

【LOOP 标记】 

功能说明:用于调用任意表的数据,一般用于调用论坛贴子之类的操作

适用范围:所有模板

(1) 基本语法

{dede:loop table=&#39; sort=&#39;&#39; row=&#39;&#39; if=&#39;&#39;}

底层模板

{/dede:loop} 

(2) 属性

  [1] table 表示查询的数据表

  [2] sort 用于排序的字段

  [3] row 返回结果的条数

  [4] if 查询条件

(3)底层模板变量

这个标记的底层模板变量即是被查询表的所有字段

例:获取Phpwind论坛的最新主题贴子

{dede:loop table=&#39;pw_threads&#39; sort=&#39;tid&#39; row=&#39;8&#39; if=&#39;&#39;}<br>
    <a href="/bbs/read.php?tid=[field:tid/]"> ·[field:subject function="cn_substr(&#39;@me&#39;,30)"/] 
      ([field:lastpost function="date(&#39;m-d H:M&#39;,&#39;@me&#39;)"/])</a> <br/>
    {/dede:loop}

【Channelartlist 标记】 

功能说明:用于获取当前频道的下级栏目的内容列表 

适用范围:封面模板 

(1)基本语法

{dede:channelArtlist typeid=0 col=2 tablewidth=&#39;100%&#39;}
<table width="99%" border="0" cellpadding="3" cellspacing="1" bgcolor="#BFCFA9">
<tr>
<td bgcolor="#E6F2CC">
{dede:type}
<table border="0" cellpadding="0" cellspacing="0" width="98%">
<tr>
<td width=&#39;10%&#39; align="center"><img src=&#39;[field:global name=&#39;cfg_plus_dir&#39;/]/img/channellist.gif&#39; width=&#39;14&#39; height=&#39;16&#39;></td>
<td width=&#39;60%&#39;>
<a href="[field:typelink /]">[field:typename /]</a>
</td>
<td width=&#39;30%&#39; align=&#39;right&#39;>
<a href="[field:typelink /]">更多...</a>
</td>
</tr>
</table>
{/dede:type}
</td>
</tr>
<tr>
<td height="150" valign="top" bgcolor="#FFFFFF">
{dede:arclist row="8"}
·<a href="[field:arcurl /]">[field:title /]</a><br>
{/dede:arclist}
</td>
</tr>
</table>
<div style=&#39;font-size:2px&#39;> </div>

{/dede:channelArtlist}  

除了宏标记外,channelArtlist 是唯一一个可以直接嵌套其它标记的标记,不过仅限于嵌套 {dede:type}{/dede:type} 和 {dede:arclist}{/dede:arclist} 两个标记。 
(2) 属性

  [1]typeid=0 频道ID,默认的情况下,嵌套的标记使用的是这个栏目ID的下级栏目,如果你想用特定的栏目,可以用","分开多个ID。 

  [2]col=2 分多列显示 

  [3]tablewidth='100%' 外围表格的大小 

【List 标记】 

功能说明:表示列表模板里的分页内容列表 

适用范围:仅列表模板 list_*.htm

(1)基本语法

{dede:list col=&#39;&#39; titlelen=&#39;&#39; 
infolen=&#39;&#39; imgwidth=&#39;&#39; imgheight=&#39;&#39; orderby=&#39;&#39; pagesize=&#39;&#39;}{/dede:list}

(2)属性
  [1]col 内容列数

  [2]titlelen 标题长度

  [3]infolen 内容摘要长度

  [4]imgwidth 缩略图宽

  [5]imgheight 缩略图高

  [6]orderby 排序方式,有效的排序方式有 senddate、pubdate、id、click、lastpost、postnum ,默认为 sortrank 

  [7]pagesize 分页大小

(3)底层模板变量 

ID(同 id),title,iscommend,color,typeid,ismake,description(同 info),postnum,lastpost,shorttitle

pubdate,senddate,arcrank,click,litpic(同 picname),typedir,typename,

arcurl(同 filename),typeurl,stime(pubdate 的"0000-00-00"格式),

textlink,typelink,imglink,image 

注:list标记除了支持档案表的基本模板变量外,还支持附加表的字段,你可以在模型管理中知道附加表支持列表使用的字段有哪些。

【Page 标记】 

功能说明:表示分页页面的附加参数 

适用范围:列表模板 

语法:

{dede:page pagesize="每页结果条数"/}

注:此标记在dedecms3.1中已经过期,dedecms3.1中直接把 pagesize属性加在 list 标记中,表示记录分页大小。

【Pagelist 标记】 

功能说明:表示分页页码列表 

适用范围:列表模板 

(1)语法

{dede:pagelist listsize=&#39;3&#39; listitem=&#39;&#39;/}

(2)属性 

  [1] listsize 表示 [1][2][3] 这些项的长度 x 2 

  [2] listitem 表示页码样式,可以把下面的值叠加

   index  首页

   pre 上一页

   pageno 页码

   next 下一页 

   end 末页

   option 下拉跳转框 

  例:

{dede:pagelist listsize=&#39;3&#39; listitem=&#39;index pre pageno next end option&#39;/}

【Pagebreak 标记】

功能说明:表示文档的分页链接列表。

适用范围:仅文档模板。 

语法:

{dede:pagebreak/}

【Prenext 标记】

功能说明:表示获取文档“上一篇/下一篇”的链接列表。

适用范围:仅文档模板。 

(1)语法:

{dede:prenext/}

(2)属性:

  [1] get 获取连接类型(仅2007版),get='' 同V4显示横排的上下页连接, get='pre' 上一篇的连接 get='next' 下一篇连接 
注:此标记默认为横向排列,如果你想用竖向排列,可以用{dede:prenext function="str_replace('   下一篇:','55e67e4c219563c7019b9d42f2222647下一篇:',@me)"/} 
表示 

【Pagetitle 标记】

功能说明:表示获取文档的分页标题

适用范围:仅文档模板。 

(1)语法:{dede:pagetitle style='select'/}

(2)属性:style 表示分页标题的展示样式

select 表示下拉框、link 表示文字直接链接

【Fieldlist 标记】

功能说明:获得附加表的所有字段信息。

适用范围:仅文档模板。 

语法:

{dede:fieldlist}
[field:name/] : [field:value/] <br>
{/dede:fieldlist}

【Myad 标记】

功能说明:获取广告代码

适用范围:所有模板。 

建议在广告管理模块中获取,在此不作描述 

##############################################################

## 以下仅适用于DedeCms2007版 

##############################################################

【Ask 标记】

功能说明:用于获取最新的问答的主题。

适用范围:非扩展模块所有模板。 

(1)语法:{dede:ask row='' qtype=''}底层模板{/dede:ask} 
(2)属性:
  [1] row 记录条数。
  [2] qtype 类型 默认为新回复问题,commend推荐问题 ok已解决问题 high高分问题 
(3)底层模板:

<dd>
<span class="tclass">[<a href=&#39;[field:typeurl/]&#39;>[field:tidname/]</a>]</span>
<span class="tlink"><a href="[field:url/]">[field:title/]</a></span>
</dd>
[field:typeurl/] 栏目网址 [field:tidname/] 栏目名称
[field:url/] 问题网址 [field:title/] 问题标题 [field:id/] 问题id

【Sql 标记】

功能说明:用于从模板中用一个SQL查询获得其返回内容。

适用范围:非扩展模块所有模板。 

(1)语法:

{dede:sql sql=""}底层模板{/dede:sql}

(2)属性:

  [1] sql 完整的SQL查询语句。

(3)底层模板:

  SQL语句中查出的所有字段都可以用[field:字段名/]来调用。

【Group 标记】

功能说明:获取特定条件的圈子。

适用范围:非扩展模块所有模板。 

(1)语法:

{dede:group row="个数" orderby=&#39;排序条件&#39; }底层模板{/dede:group}

(2)属性:

  [1] row 返回结果个数。

  [2] orderby 排序条件,一般为: 默认 threads 发贴量, members 会员数, hits 浏览量, stime 创建时间。 

  (3)底层模板:

    [field:url/]圈子网址 [field:groupname/]圈子名称 [field:icon/]圈子图标 [field:groupid/] 圈子ID

【Groupthread 标记】

功能说明:获取圈子最新发表的主题。

适用范围:非扩展模块所有模板。 

(1)语法:

{dede:groupthread gid=&#39;&#39; row=&#39;&#39; orderby=&#39;&#39; orderway=&#39;&#39;}底层模板{/dede:groupthread}

(2)属性:

  [1] gid='' 圈子分类,为空或0刚表示所有分类

  [2] row='' 条数 

  [3] orderby='' 排序条件 默认 dateline

  [4] orderway=' 排序方向 desc 或 asc 

(3)底层模板:

[field:url/]圈子网址 [field:groupname/]圈子名称 [field:icon/]圈子图标 [field:groupid/] 圈子ID

【booklist 标记】

功能说明:用于获取最新连载图书。

适用范围:连载书库。 

(1)语法:

{dede:booklist row=&#39;&#39; booktype=&#39;&#39; titlelen=&#39;&#39; orderby=&#39;&#39; catid=&#39;&#39; author=&#39;&#39; imgwidth=&#39;&#39; imgheight=&#39;&#39;}底层模板{/dede:booklist}

(2)属性:

  [1] row='' 行数 

  [2] booktype='' 图书类型 1 漫画,0 小说, -1 或默认 全部 

  [3] titlelen='' 标题长度

  [4] orderby='' 排序

  [5] catid='' 栏目ID

  [6] author='' 作者

  [7] imgwidth='' 

  [8] imgheight=''

(3)底层模板:

contenttitle,contentid,contenturl,dmbookurl,bookurl,catalogurl,cataloglink,booklink,contentlink,imglink,ischeck,booktypename

【catalog 标记】

功能说明:用于获取书库的栏目。

适用范围:连载书库。 

(1)语法:{dede:catalog type=''}底层模板{/dede:catalog} 

(2)属性:

  [1] type 类型 默认为顶级栏目,type=son 表示当前栏目的子栏目,指定特定的栏目id则为所指定的栏目。 

(3)底层模板:

本标记支持in嵌套,里面的in标记还可以再使用一重样式

{dede:catalog}
<dd><a href="{in:field name=&#39;url&#39;}{/in:field}">{in:field name=&#39;classname&#39;}{/in:field}</a></dd>
{/dede:catalog}
列出所有分类:
{dede:catalog}
<div class="book_class_form">
<dl>
<dt><a href="{in:field name=&#39;url&#39;}{/in:field}">{in:field name=&#39;classname&#39;}{/in:field}:</a></dt>
{in:sonlist}<dd> <a href=&#39;[field:url/]&#39;>[field:classname/]</a></dd>{/in:sonlist} 
</dl>
<div class="clear">
</div>
</div>
{/dede:catalog}

【chapter 标记】

功能说明:用于获取图书的章节列表,适用于book_book.htm。

适用范围:连载书库。 

(1)语法:

{dede:chapter}底层模板{/dede:chapter}

(2)底层模板:

url 网址 ch 章节 title 标题 

【contentlist 标记】

功能说明:用于获取最新图书章节。

适用范围:连载书库。 

(1)语法:

{dede:contentlist row=&#39;&#39; booktype=&#39;&#39; titlelen=&#39;&#39; catid=&#39;&#39;}底层模板{/dede:contentlist}

(2)属性:

  [1] row 条数 

  [2] booktype 图书类型 1 漫画,0 小说, -1 或默认 全部 

  [3] titlelen

  [4] catid 栏目ID

(3)底层模板: 

contenttitle,contentid,contenturl,dmbookurl,bookurl,catalogurl,cataloglink,booklink,contentlink,imglink,ischeck,booktypename

本标记实际是由booklist引申的,不同之处是按book的最新发表章节排序    

如果你想了解更多关于dedecms的知识,可以点击:dedecms教程

The above is the detailed content of How to use the dedecms tag. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn