zoukankan      html  css  js  c++  java
  • ThinkPHP 3.2.2 在 volist 多重循环嵌套中使用 if 判断标签

    今天在 ThinkPHP 3.2.2 的试图模板中使用多重循环,用来把相应类别下对应的文章都依次循环出来,但是无论如何只能循环出类别,类别下的文章无法循环出,( 错误 ) 代码如下:

    复制代码
                    <volist name="list" id="vo">
                        <tr class='{$vo.help_category_id}'>
                            <td>{$vo.help_category_id}</td>
                            <td class='display_name'>{$vo.display_name}</td>
                            <td></td>
                            <td></td>
                            <td>
                                <span class='addTopic'>
                                    <a href='#' onclick="return false">新增内容</a>
                                </span>
                                
                                <span class='cate_enabled state{$vo.is_enabled}'>
                                    <a href='#' onclick="return false"><if condition="$vo['is_enabled'] eq  1">暂停<else/>启用</if></a>
                                </span>
                                
                                <span class=''>
                                    <a href='#'>删除</a>
                                </span>
                            </td>
                        </tr>
                        <!--循环文章-->
                        <volist name="topic_list" id="topic_vo">
                            <if condition="$topic_vo.help_category_id eq $vo.help_category_id">
                                <tr>
                                    <td>{$topic_vo.topic_id}</td>
                                    <td></td>
                                    <td>{$topic_vo.title}</td>
                                    <td>{$topic_vo.priority}</td>
                                    <td><span>编辑</span> <span>暂停</span> <span>删除</span></td>
                                </tr>
                            </if>
                        </volist>
                    </volist>
    复制代码

    红色放大字体的代码即为错误代码。要正确取出数据,应该红色将代码改成:

    <if condition="$topic_vo['help_category_id'] eq $vo['help_category_id']">

    附:

    【ThinkPHP3.2.2 完全开发手册 CHM 2014-04-14】:

    由于 if 标签的 condition 属性里面基本上使用的是 php 语法,尽可能使用判断标签和 Switch 标签会更加简洁,原则上来说,能够用 switch 和比较标签解决的尽量不用 if 标签完成。因为 switch 和比较标签可以使用变量调节器和系统变量。如果某些特殊的要求下面,IF 标签仍然无法满足要求的话,可以使用原生 php 代码或者 PHP 标签来直接书写代码。

  • 相关阅读:
    导出大智慧L2要密码的公式
    SQL Server 索引结构及其使用
    职业式证券交易全貌向职业交易员进军者鉴[转]
    sqlite多字段拼接方法
    推荐两个UI、PSD文件搜索网站
    利用事件冒泡和阻止事件冒泡的例子
    js通过八个点 拖动改变div大小
    匿名函数运用js脚本一对圆括号
    js对象转换为json格式的jquery辅助类
    简单清晰的缓冲运动框架
  • 原文地址:https://www.cnblogs.com/soundcode/p/6944950.html
Copyright © 2011-2022 走看看