MODX:按组显示元素,每个组使用包装器

时间:2016-10-16 00:30:43

标签: modx modx-revolution getresource

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

<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>

至于我,这个结构与我的目的相似。我正在寻找占位符的使用示例,但是没有得到它。请用getResources或PDOTools或类似代码编写示例。

1 个答案:

答案 0 :(得分: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>