Home > CMS Tutorial > DEDECMS > body text

How does DEDECMS call the article TAG tag and add a link?

藏色散人
Release: 2020-01-07 09:19:29
Original
2587 people have browsed it

How does DEDECMS call the article TAG tag and add a link?

How does Dreamweaver DEDECMS call the article TAG tag and add a link?

How does Dreamweaver DEDECMS call the article TAG tag and add a link?

Recommended learning: 梦Weavercms

1. If it is a list page, use the following code:

[field:id runphp='yes']
global $cfg_cmspath;
$tags = GetTags(@me);
$revalue = '';
$tags = explode(',', $tags);
foreach($tags as $key => $value){
            if($value){
                $revalue .= &#39;<a href="&#39;.$cfg_cmspath.&#39;/tags.php?/&#39;.$value.&#39;/">&#39;.$value.&#39;</a> &#39;;
   }
  }
@me = $revalue;
[/field:id]
Copy after login

2. If it is a content page, use the following code :

{dede:field.id runphp=&#39;yes&#39;}
global $cfg_cmspath;
$tags = GetTags(@me);
$revalue = &#39;&#39;;
$tags = explode(&#39;,&#39;, $tags);
foreach($tags as $key => $value){
            if($value){
                $revalue .= &#39;<a href="&#39;.$cfg_cmspath.&#39;/tags.php?/&#39;.$value.&#39;/">&#39;.$value.&#39;</a>, &#39;;
   }
  }
@me = $revalue;
{/dede:field.id}
Copy after login

Code explanation

In fact, only three knowledge points are used here:

1. Use the built-in GetTags function to obtain the TAG list corresponding to the document;

2. Split the obtained value into an array using the half-width comma (,) as the standard;

3. Loop through the array elements, output the corresponding value and add a link;

At the same time, for better compatibility, the global $cfg_cmspath; method is also used here to load the program installation directory in the basic system parameters, which is used to automatically be compatible with sites installed in subdirectories when attaching links.

The above is the detailed content of How does DEDECMS call the article TAG tag and add a link?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template