Tomash Khamlai
Tomash Khamlai

Reputation: 39

MODX: display elements in groups by two with wrapper for every group

Imagine situation when you need to have output like this

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

or like this

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

As for me this structures are similar for my purpose. I was looking for examples of the usage of placeholders, but do not get it. Please write the example with getResources or PDOTools or similar.

Upvotes: 0

Views: 152

Answers (1)

Vasis
Vasis

Reputation: 2281

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

Upvotes: 1

Related Questions