We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2740
    • 95 Posts
    I’ve got a really simple problem with Ditto displaying the results on a news page. If I nest a chunk within the &tpl chunk I get a ’&tpl either does not contain any placeholders’ error.

    [!Ditto? &parents=`2` &tpl=`one`!]


    The &tpl=`one` chunk:
    <div class="news_style_one">
    {{test_code}}
    </div>


    The test_code chunk:
    <h3><a href="[~[+id+]~]">[+title+]</a></h3>


    But the result is:

    &tpl either does not contain any placeholders or is an invalid chunk name, code block, or filename. Please check it.

    However if I replace {{test_code}} with the html it works fine.

    Can anyone let me know what I’m doing wrong please?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Ditto expects to see at least one placeholder tag, link tag, or template variable tag in its template.
        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
        • 2740
        • 95 Posts
        Thanks for responding!

        In that case is there anyway to assign a class name to <div> in the Chunk based on whether it’s called by &tpl, &tplFirst or &tplLast?

        [!Ditto? &parents=`2` &tpl=`one` &tplFirst=`first` &tplLast=`last`!]


        <div class="???">
        <h3><a href="[~[+id+]~]">[+title+]</a></h3>
        </div>


        The html code in the Chunks one, first and last are identical except for the DIV class name used for styling.
          • 4172
          • 5,888 Posts
          you can try to create a TV ’dummy’ with no content and add it to your chunks:
          <div class="news_style_one">
          [+dummy+]
          {{test_code}}
          </div>
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 2740
            • 95 Posts
            Thanks Bruno17.

            That got rid of the ’&tpl either does not contain...’ error, and it processed {{test_code}} but for some reason it doesn’t return a value for [+title+], or any other placeholder except [+id+] now.

            output result
            <div class="news_style_one">
            <h3><a href="news/story1"></a></h3>
            </div>
              • 4172
              • 5,888 Posts
              perhaps you have to use [+pagetitle+] instaed of [+title+] and/or make use of the parameter &hiddenFields=`pagetitle`, because Ditto retrieves only fields, it can see in the template (and some special fields like id). May be Ditto cannot see placeholders in chunks which are included in Ditto-chunks.
              to get these for Ditto hidden fields use &hiddenFields.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 2740
                • 95 Posts
                Thanks for your suggestion again.

                I’ve had a go at using &hiddenfields but without luck. However from the description on the ditto support site it does seem that is the correct method to use. So I’ll have another attempt.
                  • 15001
                  • 697 Posts

                  @banbbc:

                  The problem you encounter is strange, but try this as it could help.
                  http://modxcms.com/forums/index.php/topic,40862.msg324330.html#msg324330

                  J.