Home  >  Article  >  Backend Development  >  Detailed introduction to the two solutions to the problem that DEDEEIMS tags cannot be nested

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

黄舟
黄舟Original
2017-04-01 09:24:501263browse

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}


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}


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}

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!

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