Home  >  Article  >  CMS Tutorial  >  How to call tag label and bring link in dedecms system list page

How to call tag label and bring link in dedecms system list page

藏色散人
藏色散人Original
2019-12-17 10:13:521698browse

How to call tag label and bring link in dedecms system list page

dedecms system list page how to call the tag tag and bring the link?

The DedeCMS system list page calls the TAG tag and brings the link. I think many webmaster friends want to achieve it. Next, I will introduce the implementation method and code explanation in detail. If you are interested, you can Don’t miss it, I hope it can help you

Recommended learning: 梦Weavercms

Implementation method

Here is the default template as an example, open /templets/default/list_article.htm Found:

The code is as follows:

<small>好评:</small>[field:scores/]

Add the following code after it:

The code is as follows:

<small>标签:</small> 
[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; 
[/field:id]

Save Then.

Note: Here I am taking the default template as an example. It is correct to open your own template and add code in the appropriate location.

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 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 install compatible files to the subsystem when additional links

directory site.

Okay, this is the content, and this is the explanation. I hope those who understand can get inspiration from it and draw inferences from one example. Looking forward to sharing your tutorials too. For those who don't understand it, it doesn't matter. You can save this code and learn about it later.

The above is the detailed content of How to call tag label and bring link in dedecms system list page. 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