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

    I have a getResources call that has tpl and tplOdd params set so that I can assign a class to every other result (it’s a list of products).

    Inside each of the template chunks named by these params there’s a call to another chunk [[$productListing]] which handles all the product data : I’ve done it this way so that I only need to manage this chunk if I need to amend the layout.

    What I get is the correct number of products for my getResources call, but the same product information repeated each time. If I switch off the tpl params, I can see that the raw output is correct.

    If I remove the [[$productListing]] call and instead replicate the code within both templates it’s fine, but there’s obviously a maintenance overhead.

    Anyone got any ideas? I suspect I’m misunderstanding something around the order of execution...

    tpl chunk:
    --------------
    <li>
    [[$productListing]]
    </li>
    --------------

    tplOdd chunk:
    --------------
    <li class="odd">
    [[$productListing]]
    </li>​
    --------------

    thanks

    Chris
      • 3749
      • 24,544 Posts
      I’m not sure I understand you, but maybe this will help. [[$productListing]] will just show the contents of that chunk (which won’t change). The only way that getResources can show data from a particular resource is with placeholder tags [[+field/TV name]], so your Tpl chunks need to have some placeholders in them (or in the productListing chunk). If you have placeholder tags in the productListing chunk, try making them and the chunk tag uncached:

      [[!$productListing]]
      [[!+field/TV name]]
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 11584
        • 3 Posts
        Hi Bob,

        Thanks for coming back. Sorry - should have pointed out that I have placeholders in the chunk, and had tried calling the chunk and placeholders uncached already.

        Not to worry - I can just maintain the 2 pieces of code, it’s not a big overhead.

        thanks

        Chris
          • 3749
          • 24,544 Posts
          If you have a significant number of products, at some point you’ll probably want to put the product data in a separate DB table and use a snippet and one or more Tpl chunks to display it.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting