We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22897 ☆ A M B ☆
    • 209 Posts
    Hi,

    I have one tree of documents in MODx representing files, that can be browsed as a Resources directory in the front-end.

    Whenever a news item/document is created, I want people to be able to select (from a multiple-select list) one or more resources to associate with the new document. I have a snippet which will list these resources at the end of every document.

    What I can’t work out is how to populate the multiple-select list. I know how to extract the details from the resource directory using Ditto (and can even ignore the folders containing the resources) but I can’t map that to a template variable binding. Is the only way to do this to use @EVAL and call the ditto snippet?

    Follow-up: This works:
    @EVAL $res = $modx->runSnippet("Ditto", array("tpl" => "@CODE:|[+title+]==[+file+]|", "parents" => "5", "hideFolders" => "1", "show" => "all", "depth" => 10)); return trim($res, '|');


    With problems:

    • There’s no way to insert option groups - when displaying resources from many categories it’d be nice to render them in category groups
    • When passed into a snippet there’s no break between multiple-items selected in a multi-select list? When I select more than one the items run together, without a newline or anything between them:
      [tt]string(152) "assets/files/Resources/United-Documents/File_1.docassets/files/Resources/SED-matches/membership_info.pdf" [/tt]. Is this meant to be the case?
      MAPLEDESIGN MODX development and MODX web design and custom development. Proud to serve UK and International clients!