We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8068
    • 3 Posts
    I’m really new to Modx, and trying to figure out how to hand Ditto a template in the tpl parameter without calling a chunk. I work for a large organization, and am responsible for a very small section of our website, so the webmaster has not given me permission to manage any Modx resources, which means I can’t create my own chunks. So, I’m trying to use @code to drop a simple template in the Ditto snippet call:

    [!Ditto? &parents=`1992` &summarize=`2` &paginate=`1` &tpl=`@CODE <h3> <a href="[~[+id+]~]" title="[+title+]">[+longtitle+]</a></h3> Posted on [+date+].
    [+content+]
    Description: [+summary+]

    ` !]

    I get this on my output page:

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

    Any help would really be appreciated.
      • 20413
      • 2,877 Posts
        @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
        • 3749
        • 24,544 Posts
        You’re in a pretty tough spot. You could definitely use @file, but the odds are the webmaster won’t let you create files either.

        I would ask the webmaster to create an empty chunk (or several if you need them) for you and add them to the document group that allows you to edit your pages. That’s easy to do and will let you edit the chunk(s) without access to anything on the rest of the site.

        If that doesn’t work, I’d try installing a copy of MODx on your own machine, dummy up the site, finish your tpl file, and ask the webmaster to paste it into a new chunk for you.
          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
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Pity that Ditto doesn’t allow the use of a document; it’s not difficult to add that to the Ditto code:
          } else if(substr($tpl, 0, 5) == "@CODE") {
          	$template = trim(substr($tpl, 5));
          } else if(substr($tpl, 0, 9) == "@DOCUMENT") {
          	$docid = trim(substr($tpl, 9));
                  $doc = $modx->getDocuments(array($docid), 1, 0, 'content');
          	$template = $doc[0]['content'];
          } else {
          	$template = $this->language['missing_placeholders_tpl'];
          }
          	return $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
            • 8068
            • 3 Posts
            Thanks guys, I’ve already got Modx set up on a personal site that I’ve been using for testing and learning, so I’ll just test my templates there and then email them to the web master.