We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12379
    • 460 Posts
    Yes, they all are getting the same template!

    put the actual tpl HTML code in the TV rather than in a chunk.

    Have you got a quick example/link of this please?
      Mostly harmless.
      • 20413
      • 2,877 Posts
      If you have 3 ditto calls in the template
      <h1>Products</h1>
      id=`one` &tpl=`default` &parents=`2` &display=`[*number*]`
      id=`two` &tpl=`[*urTV:is=`1`:then=`blue`:else=``*][*urTV:is=`2`:then=`different`:else=``*]` &parents=`2` &start=`[*number*]` &display=`1`
      
      <h2>More...</h2>
      id=`three` &tpl=`default` &parents=`2` &start=`[*number:math=`?+1`*]` &display... &paginate...
      [+three_next+]...


      And add a number TV
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 12379
        • 460 Posts
        OK, this is really pushing my MODx skills embarrassed
          Mostly harmless.
          • 3749
          • 24,544 Posts
          Quote from: BobRay at Mar 07, 2010, 11:56 PM

          Maybe I’m misunderstanding, but I don’t think any of that will work because it will all be evaluated when the Ditto tag is processed (before any items are retrieved) so all items will get the same Tpl.

          The only way I can think of to do it with Ditto is to just refer to the TV in the &tpl parameter:

          &tpl=`@CODE[+TvName+]`


          and then put the actual tpl HTML code in the TV rather than in a chunk.

          You asked for an example of this method. I can’t point you to one but let me describe it in more detail, it’s really simple.

          The code above goes in the Ditto tag as one of the of the parameters -- exactly as written (unless you use a different name for the TV). I’ve used TvName, but you can name the TV anything you want.

          Then, you create a TV called TvName which has the contents of your default Tpl chunk for its default value. IOW, you’ve got a Tpl chunk now (you do, don’t you?), just paste its contents into the TV Default Value field when you create the TvName TV. The Tpl chunk will no longer be used because the code above is telling Ditto to use the contents of the TvName TV as the Tpl.

          Then, for the documents that you want to have a different Tpl, you just edit that TV when editing those documents to give them the form that you want.

          Hope that makes sense.

          @mrhaw: If I’m understanding the OP, there is only one Ditto call on the page but, hopefully, with a different Tpl structure for certain of the documents it retrieves.
            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
            • 12379
            • 460 Posts
            Yes, that’s easy - was getting confused between your earlier explanation and @mrhaw’s last one but I can see they’re both different approaches now. So, I’ve followed your instructions but I’m getting the error:

            &tpl either does not contain any placeholders or is an invalid chunk name, code block, or filename. Please check it.
            I’ve double checked everything - Ditto call contains &tpl=`@CODE[+cell_layout+]`, have "cell_layout" set up as a TV with some random test code in the default field plus allocated it to the relevant templates, but nothing...
              Mostly harmless.
              • 3749
              • 24,544 Posts
              What’s in the cell_layout TV?

              Also, if you put the Tpl code in the default value field of the TV, you’ll have to save all documents that will be pulled by the Ditto tag so the TV won’t be empty.
                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
                • 12379
                • 460 Posts
                I stripped it back thinking it could be the problem but all I was left with was:

                <div class="cell rounded_corners clearfix">
                <p>Hello!!</p>
                </div>
                  Mostly harmless.
                  • 4172
                  • 5,888 Posts
                  I think the modx-parser replaces [+cell_layout+] before Ditto can parse and replace it.

                  you can try to create a snippet ’changechunk’ like that:


                  <?php
                  $params['tpl']='@CODE[+'.$tplTV.'+]';
                  //and your other Ditto-params:
                  $params['parents']=$parents;
                  
                  return $modx->runSnippet('Ditto',$params);
                  ?>
                  


                  replace your Ditto-call with:
                  [!changechunk? &parents=`xxx` &tplTV=`cell_layout`!]

                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 12379
                    • 460 Posts
                    Thanks - that’s definitely going to work. Only problem: the first doc content is repeated in each tpl area instead of the content of each individual document.
                      Mostly harmless.
                      • 4172
                      • 5,888 Posts
                      can you show us example-contents of your cell_layout-TV?
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!