How to use dedecms template production_PHP tutorial
Parsing engine overview Template design specifications Code reference
Tag reference: arclist(artlist,likeart,hotart,imglist,imginfolist,coolart,specart) field channel mytag vote friendlink mynews loop channelartlist page list pagelist pagebreak fieldlist
1. Overview of the DedeCms template parsing engine Before understanding the template code of DedeCms, it is very meaningful to understand the knowledge of the DedeCms template engine. The Dreamweaver 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. 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: tag name attribute = 'value'} {/dede: tag name}
{dede: tag name attribute = 'value'} Custom style template (InnerText) {/dede: tag name}
Tips:
For {dede: Tag name attribute = 'value'} {/dede: tag name} In version 2.1, only "{/dede}" is needed to indicate the end, but in
V3, "{/ dede:mark name}", otherwise an error will be reported.
2. The DreamWeaver template engine has multiple built-in system tags, which can be used directly in any situation.
(1) global tag, which means to obtain an external variable. In addition to the database password, any configuration parameters of the system can be called. The form is:
{dede:global name='variable name'}{ /dede:global}
or
{dede:global name='variable name' /}
The variable name cannot be added with the $ symbol, such as the variable $cfg_cmspath, which should be written as {dede:global name ='cfg_cmspath' /}.
(2) foreach is used to output an array, in the form:
{dede:foreach array='array name'}[field:key/] [field:value/]{/dede:foreach }
(3) include introduces a file in the form:
{dede:include file='file name' /}
The search path for files is in the order: absolute path, include file folder, CMS installation directory, CMS main template directory
3. The Dreamweaver tag allows the use of functions in any tag to process the obtained value, in the form:
{dede: tag name attribute = 'value ' function='youfunction("Parameter 1", "Parameter 2", "@me")'/}
where @me is used to represent the value of the current tag, and other parameters are determined by your function. For example:
{dede:field name='pubdate' function='strftime("%Y-%m-%d %H:%M:%S","@me")' /}
2. DedeCms template production specifications
The templates of the DedeCms system are not fixed. Users can choose the column template when creating a new column. The official only provides the most basic default template, which is each of the built-in system models. Template, DedeCms supports custom channel models. After users customize a new channel model, they need to design a new template according to the model.
1. Concept, design and use of templates, you must understand the following concepts:
1. Section (cover) template:
Refers to the template used for the homepage of the website or the cover of the more important columns, generally using " index_identification ID.htm". In addition, a single page or custom tag defined by the user can also choose whether to support section template tags. If supported, the system will use the section template tag engine to parse before outputting the content or generating a specific file.
2. List template:
It refers to the template of the list of all articles in a certain column of the website, generally named with "list_identification ID.htm".
3. File template:
Represents the template of the document viewing page, generally named with "article_identification ID.htm".
4. Other templates:
The general system generally includes templates: home page template, search template, RSS, JS compilation function template, etc. In addition, users can also customize a template to create any file.
2. Naming. For the sake of standardization, DreamWeaver officially recommends using a unified way to name templates, as follows:
1. Template saving location:
Template directory: {cmspath/templets/style name (English) , the default is default, where system is the underlying template of the system, plus is the template used by the plug-in)/specific function template file}
General template location: "/templets/default"
2. Template file naming convention:
(1) index_identification ID.htm: represents the section (column cover) template;
(2) list_identification ID.htm: represents the column list template;
(3) article_identification ID.htm : Indicates content viewing page (document template, including topic viewing page);
(4) search.htm: Search results list template;
(5) index.htm: Home page template;
Note:
The [identification IDs] of each content channel in your system are:
Example: list_image.htm means that it is the default list template for columns whose content type is picture collection.
3. Main tag reference
1. arclist tag
This tag is the most commonly used tag in DedeCms, including hotart, coolart, likeart, artlist, imglist, imginfolist, specart These tags are extended by the different attributes defined by this tag.
Function: Get a specified document list
Applicable scope: cover template, list template, document template
(1) Basic syntax:
{ dede:arclist
typeid='' row='' col='' titlelen=''
infolen='' imgwidth='' imgheight='' listtype='' orderby='' keyword=''}
Custom style template (InnerText)
{/dede:arclist}
This tag is equivalent to the artlist, imglist, and imginfolist tags, among which it is completely equivalent to artlist. Different from imglist and imginfolist, it is only the default underlying template.
(2) Attribute reference:
[1] typeid='' represents the column ID, which generally does not need to be specified in list templates and file templates, and is allowed in cover templates "," means multiple columns separately;
[2] row='' means the number of rows in the returned document. If used in combination with col, the result number is equal to row * col;
[3] col='' means How many columns to display (default is single column);
[4] titlelen='' indicates the length of the title;
[5] infolen='' indicates the length of the content introduction;
[6] imgwidth='' indicates Thumbnail width;
[7] imgheight='' indicates thumbnail height;
[8] type='' indicates file type, where the default value or type='all' is a normal document
§ When type='commend', it indicates recommended documents, which is equivalent to
§ When type='image', it indicates documents that must contain thumbnail images
[9] orderby='' indicates the sorting method, and the default value is senddate Sorted by release date.
§ orderby='hot' or orderby='click' means to sort by the number of clicks
§ orderby='pubdate' to sort 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 the pinned article)
§ orderby='id' Sort by the article ID
[10] keyword='' means containing the specified keyword Document list, multiple keywords are separated by ","
[11] channelid='number' indicates a specific channel type, built-in channels: topic (-1), article (1), gallery (2), Flash (4), software (3)
[12] limit='start, end' indicates a limited record range, the row attribute must be equal to "end - start", and the limit statement of mysql starts from 0 , such as "limit 0,5" means to take the first five records, "limit 5,5" means to take the five records starting from the fifth record.
(3) Underlying template variables
ID (same as id), title, iscommend, color, typeid, ismake, description (same as info),
pubdate, senddate, arcrank, click , litpic (same as picname), typedir, typename,
arcurl (same as filename), typeurl, stime (pubdate's "0000-00-00" format),
textlink, typelink, imglink, image
Among them:
textlink = title
typelink = typename
imglink = < ;a href='arcurl'>
image =
Variable calling method: [field:varname /]
For example:
{dede:arclist infolen='100'}
[field:textlink /]
[field:info /]
{/dede:arclist}
2. Field tag
This tag is used to obtain the field value of a specific column or file and the value of commonly used environment variables
Applicable scope: cover template, list template, document template
(1) Basic syntax
{dede:field name=''/}
(2) Value of name attribute:
Section template: phpurl ,indexurl,indexname,templeturl,memberurl,powerby,webname,specurl
List template: position,title,phpurl,templeturl,memberurl,powerby,indexurl,indexname,specurl, all fields of column table dede_arctype
Among them, position is a link in the form of "Column One > Column Two", and title is a title in this form
Document template: position,phpurl,templeturl,memberurl,powerby,indexurl,indexname,specurl,id (Same as ID, aid), all fields of the archive dede_archives table and additional tables.
3、channel 标记
用于获取栏目列表
适用范围:封面模板、列表模板、文档模板
(1)基本语法
{dede:channel row='' type=''}
自定义样式模板(InnerText)
{/dede:channel}
(2)属性
[1] row='数字' 表示获取记录的条数(通用在某级栏目太多的时候使用,默认是 8)
[2] type = top,sun,self
type='top' 表示顶级栏目
type='sun' 表示下级栏目
type='self' 表示同级栏目
其中后两个属性必须在列表模板中使用。
(3)底层模板变量
ID,typename,typedir,typelink(这里仅表示栏目的网址)
例:
{dede:channel type='top'}
[field:typename/]
{/dede:channel}
4、mytag 标记
用于获取自定义标记的内容
适用范围:封面模板、列表模板、文档模板
(1)基本语法
{dede:mytag typeid='' name='' ismake='' /}
(2)属性
[1] typeid = '数字' 表示栏目ID,默认为 0,在没有设定的栏目没有定义这个名称的标记,会按如下搜索方式来搜索“先向上查找父栏目 -> 通用标记(typeid=0)的同名标记”。
[2] name = '' 标记名称。
[3] ismake = yes|no 默认为 no 表示mytag里的内容不包含其它封面模板的标记,yes则表示标记内容含有其它封面模板标记。
5、vote 标记
用于获取一组投票表单
适用范围:封面模板
(1) 基本语法
{dede:vote id='投票ID' lineheight='22'
tablewidth='100%' titlebgcolor='#EDEDE2'
titlebackground='' tablebgcolor='#FFFFFF'}
{/dede:vote}
6、friendlink 标记,等同 flink
用于获取友情链接
适用范围:封面模板
(1)基本语法
{dede:flink type='' row='' col='' titlelen='' tablestyle=''}{/dede:flink}
属性注解:
[1]type:链接类型,值:
a. textall 全部用文字显示
b. textimage 文字和图得混合排列
c. text 仅显示不带Logo的链接
d. image 仅显示带Logo的链接
-------------------------------------
[2]row:显示多少行,默认为4行
[3]col:显示多少列,默认为6列
[4]titlelen:站点文字的长度
[5]tablestyle: 表示
{dede:type}
{/dede:type} | |||
{dede:arclist row="8"} ·[field:title /] {/dede:arclist} |
{/dede:channelArtlist}
channelArtlist is the only tag that can directly nest other tags, but it is limited to nesting
{dede:type}{/dede:type } and {dede:arclist}{/dede:arclist}
tags.
(1) Attribute
typeid=0 channel ID. By default, the nested tag uses the subordinate column of this column ID. If you want to use a specific column, you can use ", "Separate multiple IDs.
col=2 Display in multiple columns
tablewidth='100%' The size of the peripheral table
10. The page tag
indicates paging Additional parameters of the page
Scope of application: List template
Syntax:
{dede:page pagesize="Number of results per page"/}
11. The list tag
represents the content list in the list template
Syntax:
{dede:list col='' titlelen=''
infolen='' imgwidth='' imgheight='' orderby=''}{/dede:list}
Underlying template variables
ID (same as id), title, iscommend, color, typeid, ismake, description (same as info),
pubdate, senddate, arcrank, click, litpic (same as picname), typedir, typename,
arcurl (same as filename), typeurl, stime (pubdate's "0000-00-00" format ),
textlink, typelink, imglink, image
12. The pagelist tag
represents a paginated page number list
Scope of application: list template
syntax :
{dede:pagelist listsize="3"/}
listsize means [1][2][3] The length of these items x 2
13. pagebreak Tag
Purpose: Represents a paged link list of a document.
Applicable scope: document template only.
Syntax: {dede:pagebreak /}
14. fieldlist tag
Purpose: Get all field information of the attached table.
Applicable scope: document template only.
Syntax:
{dede:fieldlist}
[field:name /]: [field:value /]
{/dede:fieldlist}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics





According to news on April 26, ZTE’s 5G portable Wi-Fi U50S is now officially on sale, starting at 899 yuan. In terms of appearance design, ZTE U50S Portable Wi-Fi is simple and stylish, easy to hold and pack. Its size is 159/73/18mm and is easy to carry, allowing you to enjoy 5G high-speed network anytime and anywhere, achieving an unimpeded mobile office and entertainment experience. ZTE 5G portable Wi-Fi U50S supports the advanced Wi-Fi 6 protocol with a peak rate of up to 1800Mbps. It relies on the Snapdragon X55 high-performance 5G platform to provide users with an extremely fast network experience. Not only does it support the 5G dual-mode SA+NSA network environment and Sub-6GHz frequency band, the measured network speed can even reach an astonishing 500Mbps, which is easily satisfactory.

According to news on April 17, HMD teamed up with the well-known beer brand Heineken and the creative company Bodega to launch a unique flip phone - The Boring Phone. This phone is not only full of innovation in design, but also returns to nature in terms of functionality, aiming to lead people back to real interpersonal interactions and enjoy the pure time of drinking with friends. Boring mobile phone adopts a unique transparent flip design, showing a simple yet elegant aesthetic. It is equipped with a 2.8-inch QVGA display inside and a 1.77-inch display outside, providing users with a basic visual interaction experience. In terms of photography, although it is only equipped with a 30-megapixel camera, it is enough to handle simple daily tasks.

According to news on July 12, the Honor Magic V3 series was officially released today, equipped with the new Honor Vision Soothing Oasis eye protection screen. While the screen itself has high specifications and high quality, it also pioneered the introduction of AI active eye protection technology. It is reported that the traditional way to alleviate myopia is "myopia glasses". The power of myopia glasses is evenly distributed to ensure that the central area of sight is imaged on the retina, but the peripheral area is imaged behind the retina. The retina senses that the image is behind, promoting the eye axis direction. grow later, thereby deepening the degree. At present, one of the main ways to alleviate the development of myopia is the "defocus lens". The central area has a normal power, and the peripheral area is adjusted through optical design partitions, so that the image in the peripheral area falls in front of the retina.

According to news on April 3, Taipower’s upcoming M50 Mini tablet computer is a device with rich functions and powerful performance. This new 8-inch small tablet is equipped with an 8.7-inch IPS screen, providing users with an excellent visual experience. Its metal body design is not only beautiful but also enhances the durability of the device. In terms of performance, the M50Mini is equipped with the Unisoc T606 eight-core processor, which has two A75 cores and six A55 cores, ensuring a smooth and efficient running experience. At the same time, the tablet is also equipped with a 6GB+128GB storage solution and supports 8GB memory expansion, which meets users’ needs for storage and multi-tasking. In terms of battery life, M50Mini is equipped with a 5000mAh battery and supports Ty

According to news on May 13, vivoX100s was officially released tonight. In addition to excellent images, the new phone also performs very well in terms of signal. According to vivo’s official introduction, vivoX100s uses an innovative universal signal amplification system, which is equipped with up to 21 antennas. This design has been re-optimized based on the direct screen to balance many signal requirements such as 5G, 4G, Wi-Fi, GPS, and NFC. This makes vivoX100s the mobile phone with the strongest signal reception capability in vivo’s history. The new phone also uses a unique 360° surround design, with antennas distributed around the body. This design not only enhances the signal strength, but also optimizes various daily holding postures to avoid problems caused by improper holding methods.

According to news on July 29, the Honor X60i mobile phone is officially on sale today, starting at 1,399 yuan. In terms of design, the Honor X60i mobile phone adopts a straight screen design with a hole in the center and almost unbounded ultra-narrow borders on all four sides, which greatly broadens the field of view. Honor X60i parameters Display: 6.7-inch high-definition display Battery: 5000mAh large-capacity battery Processor: Dimensity 6080 processor (TSMC 6nm, 2x2.4G A76+6×2G A55) System: MagicOS8.0 system Other features: 5G signal enhancement, smart capsule, under-screen fingerprint, dual MIC, noise reduction, knowledge Q&A, photography capabilities: rear dual camera system: 50 million pixels main camera, 2 million pixels auxiliary lens, front selfie lens: 8 million pixels, price: 8GB

Since the launch of ChatGLM-6B on March 14, 2023, the GLM series models have received widespread attention and recognition. Especially after ChatGLM3-6B was open sourced, developers are full of expectations for the fourth-generation model launched by Zhipu AI. This expectation has finally been fully satisfied with the release of GLM-4-9B. The birth of GLM-4-9B In order to give small models (10B and below) more powerful capabilities, the GLM technical team launched this new fourth-generation GLM series open source model: GLM-4-9B after nearly half a year of exploration. This model greatly compresses the model size while ensuring accuracy, and has faster inference speed and higher efficiency. The GLM technical team’s exploration has not

According to news on July 19, Xiaomi MIX Fold 4, the first flagship folding new phone, was officially released tonight and is equipped with a "three-dimensional special-shaped battery" for the first time. According to reports, Xiaomi MIX Fold4 has achieved a major breakthrough in battery technology and designed an innovative "three-dimensional special-shaped battery" specifically for folding screens. Traditional folding screen devices mostly use conventional square batteries, which have low space utilization efficiency. In order to solve this problem, Xiaomi did not use the common winding battery cells, but developed a new lamination process to create a new form of battery, which greatly improved the space utilization. Battery Technology Innovation In order to accurately alternately stack positive and negative electrode sheets and ensure the safe embedding of lithium ions, Xiaomi has developed a new ultrasonic welding machine and lamination machine to improve welding and cutting accuracy.
