We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8109
    • 128 Posts
    I have a call like this:

    [[Ditto? &sortBy=`menuindex` &sortDir=`ASC` &filter=`pagetitle,Special,7` &display=`all` &tpl=`@CODE:[+longtitle+]` ]]


    if I leave out the &tpl part, I get the standard Ditto output. But with this @CODE, I get the following error:

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


    I’ve tried some variations, such as:

     &tpl=`@CODE:<p>[+longtitle+]</p>`
     &tpl=`@CODE:<p>hello world</p>`
    


    And I’ve tried with and without the colon, which does not appear in the Ditto documentation, but does in appear in the one other post I’ve found on this subject. Does anyone have experience with it?

      Revo 2.0.8-pl
      • 36592
      • 970 Posts
      Try space instead of colon like ...
      &tpl=`@CODE [+longtitle+]`
        • 8109
        • 128 Posts
        Has this worked for you? Sadly, it does not work for me, though it is, of course, what I first tried.
          Revo 2.0.8-pl
          • 36592
          • 970 Posts
          Quote from: drwagner13 at Aug 29, 2009, 12:45 PM

          Has this worked for you?
          Yes. Then change cached form [[...]] to uncached form [!...!].
            • 8109
            • 128 Posts
            Still no love. undecided Yet replacing the CODE statement with the name of a chunk with the same code inside works, so I know the rest of the snippet call is correct.
              Revo 2.0.8-pl
            • You can’t have HTML code inside params, but you can if you use config files or have the code actually in a containing chunk.
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 8109
                • 128 Posts
                Well, this is in direct contraction to the ditto documentation that says you can have html in the ditto call using &tpl=`CODE@...`

                But since the &where statement doesn’t work either, this comes as no surprise.
                  Revo 2.0.8-pl
                  • 3749
                  • 24,544 Posts
                  This should definitely work.

                  Here’s the $default tpl created in the Ditto constructor:

                  $default = '@CODE<div class="ditto_item" id="ditto_item_[[+id]]">
                              <h3 class="ditto_pageTitle"><a href="[[~[[+id]]]]">[[+pagetitle]]</a></h3>
                              <div class="ditto_documentInfo">by <strong>[[+author]]</strong> on [[+date]]</div>
                              <div class="ditto_introText">[[+introtext]]</div>
                          </div>';
                  


                  In the Ditto Template class, it looks like the colon is optional:
                      else if(substr($tpl, 0, 6) == "@CODE:") {
                          $template = substr($tpl, 6);
                  . . .
                      else if(substr($tpl, 0, 5) == "@CODE") {
                          $template = trim(substr($tpl, 5));
                  
                  



                  Here’s the code that’s generating your error message (bad_tpl) it’s in assets/snippets/ditto/classes/template.class.inc.php:
                  foreach ($templates as $tplName=>$tpl) {
                      $check = $this->findTemplateVars($tpl);
                      if (is_array($check)) {
                          $fieldList = array_merge($check, $fieldList);
                      } else {
                          switch ($tplName) {
                              case "base":
                                  $displayName = "tpl";
                  		break;
                  					
                  	    case "default":
                  	        $displayName = "tpl";
                  	        break;
                  					
                  	    default:
                  	        $displayName = "tpl".$tplName;
                  	        break;
                  	    }
                  	    $templates[$tplName] = str_replace("[+tpl+]",$displayName,$this->language["bad_tpl"]);
                      }
                  }
                  


                  You could try just commenting out that last line. It looks like it will execute any time you have a template that doesn’t contain any template variables. I don’t know why.
                    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
                    • 8109
                    • 128 Posts
                    Yes, but my CODE does have a template variable (longtitle)! Wah. That all the links on the Ditto home page are broken (notably the bug report link) and the fact that that site hasn’t been updated in 2 years bodes poorly for this situation.
                      Revo 2.0.8-pl
                      • 10449
                      • 956 Posts
                      I just did a quick test with the default install of Evo 1.0:

                      <ul>
                      [!Ditto? &sortBy=`menuindex` &sortDir=`ASC` &display=`all` &parents=`15` &tpl=`@CODE <li>[+longtitle+]</li>`!]
                      </ul>
                      


                      That works here as expected. Do you have perhaps tinyMCE active on that particular page? I would deactivate it. Maybe some WYSIWYG stuff gets in the way...