【问题标题】:MODX: display elements in groups by two with wrapper for every groupMODX:按两个分组显示元素,每个组都有包装器
【发布时间】:2017-02-25 05:04:40
【问题描述】:

想象一下你需要这样的输出的情况

<table>
    <tr class="row">
        <td class="cell">First resource</td>
        <td class="cell">Second resource</td>
    </tr>
    <tr class="row">
        <td class="cell">Third resource</td>
        <td class="cell">Fourth resource</td>
    </tr>
    <tr class="row">
        <td class="cell">Fifth resource</td>
        <td class="cell">Sixth resource</td>
    </tr>
</table>

或者像这样

<div class="container">
    <div class="row"><!--groups-->
        <div class="col-md-6">
            First resource
        </div>
        <div class="col-md-6">
            Second resource
        </div>
        <div class="clearfix"> </div>
    </div>
    <div class="row"><!--group-->
        <div class="col-md-6">
            Third resource
        </div>
        <div class="col-md-6">
            Fourth resource
        </div>
        <div class="clearfix"> </div>
    </div>

    <div><!--group-->
        ...
    </div>

    ...
    ...
</div>

就我而言,这些结构与我的目的相似。我一直在寻找 placeholders 用法的示例,但不明白。请使用 getResources 或 PDOTools 或类似方法编写示例。

【问题讨论】:

    标签: modx modx-revolution getresource


    【解决方案1】:
    [[pdoResources?
        &parents=`0`
        &depth=`1`
        &tplFirst=`tplFirst`
        &tpl=`tpl`
        &tplOdd=`tplOdd`
        &tplLast=`tplLast`
        &tplWrapper=`tplWrapper`
    ]]
    

    tplFirst

        <tr class="row">
            <td class="cell">[[+pagetitle]]</td>
    

    tpl

            <td class="cell">[[+pagetitle]]</td>
    

    tplOdd

            <td class="cell">[[+pagetitle]]</td>
       </tr>
       <tr class="row">
    

    tplLast

            <td class="cell">[[+pagetitle]]</td>
        </tr>
    

    tplWrapper

    <table>
        [[+output]]
    </table>
    

    【讨论】:

      猜你喜欢
      • 2018-02-11
      • 2019-09-30
      • 1970-01-01
      • 2017-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 2014-12-03
      相关资源
      最近更新 更多