We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12508
    • 63 Posts
    Hi there!

    I want to do something using getPage & getResources but I’m not sure if it can work. I need to display on an overview page a table with content from other documents. The challenge here is that the content should be displayed on a 3 columns table.

    The problem? I don’t know how to add a “</tr> <tr>” tag after every 3 obtained documents, in other words, automatically create a row every 3 docs.

    This is the way I need the code:

    <table>
    <tr>
    <td> Doc 1 </td>
    <td> Doc 2 </td>
    <td> Doc 3 </td>
    </tr>
    <tr>
    <td> Doc 4 </td>
    <td> Doc 5 </td>
    <td> Doc 6 </td>
    </tr>
    </table>


    I can do a container template with:

    <table>
    <tr>
    [[!getPage? &element=`getResources` &parents=`[[*id]]`]]
    </tr>
    </table>


    And the template for getResources can be something like:
    <td> [[+content]] </td>

    But this will create a huge table with many columns, and I need only 3 columns for each row.

    Does anybody knows how to solve this problem?

    I will really appreciate any help
      • 12508
      • 63 Posts
      here I’m again,

      I’ve been trying to use the tpl_{n} property without any result. I don’t know if this property can’t help or maybe I’m doing something wrong.
      For example, I do:

      &tpl_{3n}=`tmplName` - dones’t work
      &tpl_{3}=`tmplName` - doesn’t work
      &tpl_{n3}=`tmplName` - doesn’t work

      any comments?
      Thanks in advance
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Does it really have to be in a table? When I want something in neat rows like that I use an outer container, then each item is in its own container. These inner containers are floated, sized and spaced with css so that they fit in the outer container. If I have them sized so that three inner blocks fit in the outer container, then the fourth one drops to the next line below; the same with the seventh, the tenth, etc. It’s all done with the css.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 12508
          • 63 Posts
          Thanks Susan for your answer,

          I tried the way you described, but it doesn’t work on IE7. (It works on all other browsers). Sadly I have to consider the old IE crap and use a table to ensure compatibility.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            It’s just a matter of adjusting the sizing, borders and margins; IE counts the pixels differently. I usually have an IE conditional block with a few IE-specific style rules to "fix" things for IE. Since it follows the general css file link these styles will override the general ones.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 22019
              • 390 Posts
              Not exactly efficient but you could use the &offset parameter and multiple getResources calls to call the content in groups of three.

              Or, untested so this might not work, have you tried multiple tplnames for multiples of three in the same call - it doesn’t say you can’t do this....
              &tpl_3=, &tpl_6=, &tpl_9=.

              You might be able to do that on one line by adding &outputSeparator=`,` - based on my limited reading of the snippet code.
                Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
                • 12508
                • 63 Posts
                thanks Susan & Ivan,

                I found a solution based on your answers. I throw away the table and use instead divs as Susan recommends. Then I used multiple getResources calls using the offset parameter as Ivan describe and Bum! it works even in IE7.

                Thank you guys again for your support.