We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33114
    • 518 Posts
    Say I have a template chunk for Ditto where I call a snippet.
    <div>
     <h2>[+pagetitle+]</h2>
     <p>[+introtext+]</p>
     [[Snippet]]
    </div>


    Can I somehow pass to or get from inside that snippet an entry’s id (wich is stored in [+id+] placeholder)
    PHx variant works well: [+id:Snippet+] - I get the id in $output, but is there some other way?
    [[Snippet? &id=`[+id+]`]] is not working (at least correctly)
      http://modx.ru - российская поддержка MODx
      http://newscup.ru - экспериментальный проект
      http://yentsun.com - персональный сайт
      • 25663 MODX Staff
      • 12,272 Posts
      Try calling snippet uncached... maybe?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 33114
        • 518 Posts
        tried that by default already Ryan, looks like Ditto sets the same id for all entries (concerning my snippet parameter). That is if I call the snippet cached the output looks like:

        artist4
        artist4
        artist4
        artist4
        (yeah - artist4, not artist1... it outputs multiple instances of the last entry for some reason)

        instead of

        artist1
        artist2
        artist3
        artist4

        and when I call the snippet uncached - I get the following:

        artist3
        artist3
        artist3
        artist3

        :)

        I can do with PHx style of snippet, but it seems to make more DB requests, and I am optimizing for a heavy-load production site.
          http://modx.ru - российская поддержка MODx
          http://newscup.ru - экспериментальный проект
          http://yentsun.com - персональный сайт
          • 33114
          • 518 Posts
          Mark? Is this model: [[Snippet? &id=`[+id+]`]] supposed to work anyways in a Ditto tpl chunk? I guess this works ok for Jot for example.
          [[Jot? &action=`count-comments` &docid=`[+id+]`]]
          - working
            http://modx.ru - российская поддержка MODx
            http://newscup.ru - экспериментальный проект
            http://yentsun.com - персональный сайт
            • 18397
            • 3,250 Posts
            So long as the snippet calls alternate (Ditto called cached, snippet inside tpl uncached or vice versa) snippets should in Ditto templates.