We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22891
    • 17 Posts
    In the MODx Wiki, Ditto_Placeholders mentions near the bottom:
    [+item[x]+] – rendered output of an individual document

    How is this used?

    I have a series of pages that are essentially HTML snippets chunks fragments and want Ditto to grab them and make a list using the full rendered document, but all it makes are summaries.

    I thought the above placeholder would render each page in its entirety, say where x is the doc id. I think I tried:
    [*][+item[19]+]
    [*][+item[+id+]+]
    [*][+item[[+id+]]+]
    [*][+item[{{doc_id}}]+] (where {{doc_id}} is a chuck capturing the id from elsewheres)
    [*]and variations.
    No success.

    Calling the page (here #19) on its own gives the proper HTML output, but it’s not in the page template where it should be.

    Ideas?


    eek. my first post.
      • 36592
      • 970 Posts
      I’ve never used this placeholder before, but in my understanding ’x’ does not mean document ids.
      I think it is the serialized number like 0,1,2... of the output of Ditto result.
        • 10449
        • 956 Posts
        Create a chunk with nothing but [+content+] in it. Let’s say you call that chunk ’contentTPL’.
        Then, your Ditto call would look something like: [!Ditto? &tpl=`contentTPL` &parents=`10`!]
        add other parameters as needed...

        You can also use the @CODE syntax:
        [!Ditto? &tpl=`@CODE [+content+]` &parents=`10`!]
        However, if you’re using ? = & characters in your tpl, it’s safer to use chunks. These chars can’t get passed via snippet parameters.
          • 22891
          • 17 Posts
          Using [+content+]/@CODE [+content+] mostly works. Unfortunately I have template variables assigned to the page in question since there are several standard parts to it that I want to be sure to fill out. Since they are outside of the content proper, they’re not rendered. undecided

          Technically my "template" is a page template. But if I put that into &tpl it gives me:
          &tpl either does not contain any placeholders or is an invalid chunk name, code block, or filename. Please check it.

          Thanks for the responses.
            • 10449
            • 956 Posts
            well, try to copy the page-template into the Ditto-chunk-template and see if this is getting rendered correctly.
              • 22891
              • 17 Posts
              That appears to have done it. Wow.

              Since this is the first time I’ve actually tried to build an entire site with MODx, I’m sure there are more efficient methods that I’m missing, but this works. Thank you!
                • 22891
                • 17 Posts
                Chunk (partial):
                <h1><a name="post[+id+]"> </a>[+pagetitle+]</h1>
                <ul class="postinfo">
                	<li class="timestamp">[+pub_date+]</li> ...

                Ditto call:
                [!Ditto? &parents=`9` &depth=`1` &dateFormat=`%d %b %Y` &display=`all` &tpl=`docuChunk`!]

                Ditto is now returning the pub_date as Unix time vs. dd Mmm YYYY (e.g. 15 Aug 2008). Hrm...
                  • 7231
                  • 4,205 Posts
                  Set &dateSource=`pub_date` and then set the &dateFormat=`` to format the date. Then in your template use [+date+] placeholder.

                  OR

                  Use one of the date formatting snippets available to format the date output. Modx stores all dates in timestamps.
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 22891
                    • 17 Posts
                    Ah! dateSource + [+date+] does the trick. Thanks again, all!