Home >CMS Tutorial >DEDECMS >DedeCMS custom macro tag usage

DedeCMS custom macro tag usage

(*-*)浩
(*-*)浩Original
2019-11-15 16:23:283021browse

In template production, we often encounter the problem of some website tags being called on multiple pages. Usually we can pass the {dede:include file='file name' of the template ismake='whether it is a dede section template (yes /no)'/} tag imports a file to solve.

DedeCMS custom macro tag usage

The head.htm in the default template of version 5.3 of DedeCMS is introduced into other template files through such tags, and then compiled into page header information , but this way of introducing it in the form of a file is not suitable for global display of a small amount of content. (Recommended learning: dedecms tutorial)

For example, you may have a column that needs to be displayed globally, and the calling information of this column will change frequently, but only involves one paragraph. Code, if you use {dede:include/}, it is difficult to implement. At this time, you need to customize macro tags to solve this flexible calling problem. In fact, Dreamweaver's advertising plug-in is also another form of macro tag.

Before learning about custom macro tags, we first consult the template tag section of the Dreamweaver Help Center for an introduction to the use of custom macro tags:

The following is the quoted content:

Tag name: mytag

Function description: used to obtain the content of custom macro tags

Applicable scope: global use

Basic syntax: {dede:mytag typeid='0' name=''/}

Parameter description:

name = '' tag Name, this item is a required attribute, the following 2 and 3 are optional attributes;

ismake = 'yes|no' The default is no, which means the set pure HTML code, yes means the code containing section tags;

typeid = '' indicates the ID of the column to which it belongs. The default is 0, which indicates the common display content of all columns. In lists and document templates, typeid defaults to the column ID of the list or document itself.

There are three main steps for using custom macro tags: generating tags, adding templates, and content generation. Let’s explain how to use this tag from these processes.

Generate tags

The new version V5.3 adds custom macro tags that can automatically generate and add dreamweaver tags. This is similar to the template fragment function . The first is to add a tag directly. You can click [Template]-[Custom Macro Tag] to enter the custom macro tag management page and add a tag.

DedeCMS custom macro tag usage

Several parameters need to be introduced here:

Column: If not selected, it will be performed in all columns Display, if a column is selected, the custom macro tag will only be displayed in the currently selected column

Tag name: a name used to distinguish different tags, it is recommended to use a collection of English and numbers

Normal display content: the content that is replaced when the tag is parsed, which can be plain text, HTML, or even the DreamWeaver tag

If you select the time limit, you can also control the display time of the tag. This makes it easy to manage these contents in a unified manner, which is very convenient.

After completing the addition, we will get the corresponding tag. For example, if our custom tag name is diyinfo, then our tag name will be {dede:mytag name='diyinfo'}. If the tag is HTML or plain The text content can set the ismake attribute to no. If the Dreamweaver tag is added, set the ismake attribute to yes.

The second method is to generate a label in the system [Template]-[Smart Tag Wizard], and then save it as a custom macro tag. The default file name saved is auto_x (x represents a number, starting from 1 ), thus obtaining his tag code as {dede:mytag name='auto_1' ismake='yes'/}.

Of course, custom macro tags can be called not only through the Dreamweaver tag, but also through js. On the custom tag management page, there is a corresponding js generation wizard behind each tag. , users can generate js code and insert it into the website template.

Add template

Custom macro tags can be added to the home page, channel page, list page, and content page in the template at will. The relative template file path is in the weaving The "Main Template Files and Function Descriptions" of the Meng Help Center have been listed, you can refer to it when making modifications.

Content generation

If the custom macro tag is added to the template using the Dreamweaver tag, all content of the website needs to be updated regularly, but if you are The template uses js code, which only needs to be generated once and can be used continuously.

The following is the quoted content:

Note: Dreamweaver tags and js are two calling forms of custom tags. The former is more suitable for regular site-wide updates of the website, and the generated content is directly nested into the generated page. The latter is more suitable for small updates of the website, but More convenient to manage. The advertising plug-in here is actually an extension of the custom macro tag, and the calling form is somewhat the same.

At this point, we have completed the study of custom macro tags. Of course, custom macro tags have many applications. We look forward to more DreamWeaver users discovering them.

The above is the detailed content of DedeCMS custom macro tag usage. 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