Of course! The "myad" name in the context of DedeCMS (织梦CMS) is a core part of its advertising management system.
Here’s a detailed breakdown of what myad is, how it works, and how you use it.
What is myad?
myad is the tag name used in DedeCMS to call and display advertisements that have been created in the backend admin panel. It's not a single file but rather a tag that references the DedeCMS ad management system.
Think of it as a placeholder. You place the {dede:myad} tag in your website's template files (.htm), and when the page loads, DedeCMS replaces that tag with the actual ad code you've configured.
The Main Tag: {dede:myad}
This is the most common tag you will use. Its primary function is to display a specific advertisement based on its unique identifier.
Syntax:
{dede:myad name='广告标识符'/}
Key Attribute: name
name='广告标识符': This is the required attribute. It tells DedeCMS which ad to display.- The "广告标识符" (Ad Identifier) is the unique name you give an ad when you create it in the backend. It's not the ad's title or description, but a short, machine-friendly name (like
top_banner,sidebar_ad,footer_link).
How to Use myad: A Step-by-Step Guide
To use the myad tag, you first need to create an ad in the DedeCMS admin panel.
Step 1: Create the Ad in the Backend
- Log in to your DedeCMS admin panel.
- Navigate to 核心 (Core) -> 广告管理 (Ad Management).
- Click 新增广告 (Add New Ad).
- Fill in the details for your new ad:
- 广告名称 (Ad Name): A human-readable name for you to recognize it (e.g., "首页顶部横幅").
- 广告标识 (Ad Identifier): This is the most important field for the
{dede:myad}tag. It must be unique and contain no spaces or special characters (e.g.,home_top_banner). This is the value you will use in thenameattribute. - 广告位置 (Ad Position): This is a legacy field but can still be used for basic filtering.
- (Ad Content): This is where you paste the code for your ad. This can be:
- HTML code (e.g.,
<a href="..."><img src="..."></a>) - JavaScript code (e.g., from Google AdSense or an ad network)
- Plain text
- HTML code (e.g.,
- 启用状态 (Status): Make sure this is set to "是" (Yes) to make the ad active.
- Click 确定 (Save).
Step 2: Place the Tag in Your Template
Now that you have an ad with the identifier home_top_banner, you can place it on your website.
- Go to 模板 (Templates) -> 模板管理 (Template Management).
- Find the template file for the page where you want the ad to appear (e.g.,
index.htmfor the homepage). - Edit the template file and add the
{dede:myad}tag where you want the ad to show up.
Example:
Let's say you want to place your "首页顶部横幅" ad at the very top of your homepage. You would edit index.htm and add this tag:
<!DOCTYPE html>
<html>
<head>{dede:global.cfg_webname/}</title>
</head>
<body>
<!-- Place the ad tag here -->
{dede:myad name='home_top_banner'/}
<h1>Welcome to our Website</h1>
<!-- other content... -->
</body>
</html>
When you visit your homepage, DedeCMS will render this tag and display the ad content you added in Step 1.
Other Related myad Tags
DedeCMS also has other ad-related tags for more specific use cases.
{dede:myad} (with the typeid attribute)
This tag is used to display ads that are associated with a specific channel (栏目) or content ID. This allows for more targeted advertising.
Syntax:
{dede:myad name='广告标识符' typeid='栏目ID'/}
typeid: The ID of the DedeCMS channel. The ad will only be displayed on pages belonging to that channel.
{dede:ad} (The "newer" ad tag)
In newer versions of DedeCMS, {dede:ad} is introduced as a more powerful and flexible tag. It can display multiple ads from a single "广告位" (Ad Position) and supports features like randomization and weighting.
Syntax:
{dede:ad name='广告位名称' type='广告类型'/}
name: The name of the "广告位" (Ad Position), not the ad's identifier. You create ad positions in the backend.type: The type of ad (e.g.,image,flash,text).
Summary
| Tag | Purpose | Key Attribute | Example |
|---|---|---|---|
{dede:myad} |
Display a single, specific ad by its unique identifier. | name='广告标识符' |
{dede:myad name='sidebar_ad'/} |
{dede:myad} |
Display an ad for a specific channel. | name='...' and typeid='...' |
{dede:myad name='channel_ad' typeid='5'/} |
{dede:ad} |
Display ads from a designated ad position, can be multiple/random. | name='广告位名称' |
{dede:ad name='top_banner'/} |
For most simple needs, you will be using {dede:myad name='your_ad_identifier'/}. Just remember to set a unique and clear "广告标识" when creating your ad in the backend.
