Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use DedeCMS custom macro tag

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to use DedeCMS custom macro tags. I hope you will gain a lot after reading this article. Let's discuss it together.

In template making, we often encounter the problem that some website tags are called on multiple pages. Usually we can import a file through the template {dede:include file=' file name 'ismake=' is dede template (yes/no)' /} tag.

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 introduction as a file is not suitable for the global display of a small amount of content.

For example, you may have a column that needs to be displayed globally, and the call information of this column will often change, but only a piece of code is involved. If you use {dede:include/}, it is difficult to implement, so you need to customize macro tags to solve the problem of flexible call. In fact, the advertising plug-in for weaving dreams is another form of macro markup.

Before learning about custom macro tags, let's take a look at the template tags section of the Dream weaving help Center for an introduction to the use of custom macro tags:

The following is the referenced content:

Tag name: mytag

Function description: used to get the content of a custom macro tag

Scope of application: global use

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

Parameter description:

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

Ismake = 'yes | no' defaults to the pure HTML code set by no, and yes represents the code with section marks.

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

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

Generate label

The new version v5.3 adds custom macro tags that can be automatically generated and added to dream tags, which is similar to template fragmentation. The first is to add tags directly. You can click "template"-"Custom Macro tag" to enter the custom macro tag management page and add a tag.

Several parameters need to be introduced here:

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

Tag name: a name used to distinguish between different tags. A collection of English and numbers is recommended.

Normal display content: the content that the tag is replaced during parsing can be plain text, HTML, or even dream-weaving tags.

If you choose the time limit, you can also control the display time of the label, so it is convenient to manage these contents uniformly.

After adding, we get the corresponding tag. For example, if our custom tag signature is diyinfo, then our tag name is {dede:mytag name='diyinfo'}. If the tag is HTML or plain text content, you can set the ismake attribute to no, and if you add a dream weaving tag, set the ismake attribute to yes.

The second method is to generate a tag in the system [template]-[Smart tag Wizard], and then save it as a custom macro tag. The default file name is auto_x (x stands for numbers, starting with 1), so that the tag code is {dede:mytag name='auto_1' ismake='yes'/}.

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

Add template

Custom macro tags can be arbitrarily added to the home page, channel page, list page, and content page of the template. The relative template file path is listed in the "main template File and function description" of the Dream weaving help Center.

Content generation

If custom macro tags are added to the template using dream tags, you need to update everything on the site periodically, but if you use js code in the template, you only need to generate it once to use it all the time.

The following is the referenced content:

Description: dream tag and js are two call forms of custom tags, the former is more suitable for regular site-wide updates, and the generated content is directly nested into the generated page, the latter is more suitable for a small number of site updates, but more convenient to manage. Here the advertisement plug-in is actually an extension of the custom macro tag, and the invocation form is somewhat the same.

After reading this article, I believe you have a certain understanding of how to use DedeCMS custom macro tags, want to know more about it, welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report