Detailed introduction to the two solutions to the problem that DEDEEIMS tags cannot be nested

黄舟
Release: 2023-03-07 08:40:02
Original
1260 people have browsed it

This article mainly introduces two solutions to the problem that the DEDEEIMS tag cannot be nested, that is, the solution to the problem that the dede tag cannot be parsed normally when another dede tag is nested. Friends in need can refer to the following The following tags:

The code is as follows:

{dede:
list
 pagesize=’6′}
<li><a href="/plus/jobs.php?
lang
={dede:global.user_lang/}&jobid=[field:id/]">[field:jobname/]</a></li>
{/dede:list}
Copy after login


When running, it was found that {dede:global.user_lang/} was actually displayed intact. came out but was not parsed, I was very puzzled, so I went to the Internet to search for solutions to the problem that DEDECMS cannot nest tags, and finally found two solutions.

Option One:

<!–在标签之前,先用
JS
获取标签中需要得到的内容–>
<script type="text/
javascript
">
function get_user_lang(){
  
document
.write("{dede:global.user_lang/}");
}
</script>
{dede:list pagesize=’6′}
<!–然后在标签中调用该JS
函数
把内容给显示出来–>
<li><a href="/plus/jobs.php?lang=<script type="text/javascript">get_user_lang();</script>&jobid=[field:id/]">[field:jobname/]</a></li>
{/dede:list}
Copy after login


Obviously, this method is definitely not what I want, because this method is not only complicated, but also not easy to maintain, and more importantly It is contrary to my habit of insisting on the separation of behavior and structure as much as possible, so I searched on the Internet and found a more convenient solution, which is to change {dede:global.user_lang/} to [ field:global.user_lang/].

Option 2:

{dede:list pagesize=’6′}
<li><a href="/plus/jobs.php?lang=[field:global.user_lang/]&jobid=[field:id/]">[field:jobname/]</a></li>
{/dede:list}
Copy after login

dedecms template download address: www.php.cn/xiazai/code/dedecms

Isn’t it very simple? This method is not only simple, but also easy to maintain. It is also in line with the good practice of separating structure and behavior. Of course, it is applicable to other tags or in DEDECMS.

The above is the detailed content of Detailed introduction to the two solutions to the problem that DEDEEIMS tags cannot be nested. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!