We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2954
    • 40 Posts
    I’ve searched the existing document on template variable bindings and @DOCUMENT and can’t find any example of how to use it.

    What I’m trying to do is create a list of documents within a template variable. So...

    Input Option Values:

    @SELECT pagetitle from modx_site_content where parent=@DOCUMENT parent

    Thanks for the help!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That won’t work. The @-bindings only work one at a time. The @DOCUMENT binding only takes the ID of the desired resource as an argument, and simply returns the content field of the specified resource.

      For your purposes, you’d need a snippet to set a placeholder with the ID, then use the placeholder in the TV:

      The snippet:
      $modx->setPlaceholder('thisParent', $modx->documentObject['parent']);
      return;
      


      The TV:
      @SELECT * FROM [+PREFIX+]site_content WHERE parent='[+thisParent+]'
      


      Are you sure a TV is the best way to do this? A snippet using getAllChildren() or getActiveChildren() might be a better solution.

      http://wiki.modxcms.com/index.php/API:getAllChildren
        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