We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24495
    • 407 Posts
    Hi, because I’m not a programmer I need some help/hints to implement following idea.

    For a marginal column I want to put a tv where I collect id’s from documents I publish in this marginal column. The idea is to put this documents in any order I wish. For example the content of the TV should be:
    52, 16, 4, 88


    The marginal column should contain the contents of documents 52, 16, 4, 88 is this order.
    Think I need a snippet reading the TV content and returns a multiple getfield?

    Thanks for ideas/hints.
      • 24495
      • 407 Posts
      hrmm ... no ideas?
        • 18397
        • 3,250 Posts
        So your saying the TV’s value would be a list of IDs and you want a snippet to take that and show those documents in that order?
          • 24495
          • 407 Posts
          Yes but not a list. I want to put only the IDs of the documents into the TV (input type: text) separated by commas or blanks. The snippet should grab the content of the document’s identified by the IDs. The snippet output should be:
          foreach id(x) -> get the content field of document with id(x)
          return multiple 'some html'.content(x).'another html'


          I think that this TV filling is easy enough for my clients. So they can define the elements in marginal column in an easy way. A TV with a pre-defined list of IDs can’t work, because my clients should have a chance to define a customized order of the documents they wish to include in the marginal column.
            • 18397
            • 3,250 Posts
            A "list" of IDs is what I meant. You should be able to use a snippet like this to do what you wish:

            $ids = explode(", ",$ids);
            $output = "";
            foreach ($ids as $id) {
            $doc = $modx->getDocument($id);
            $output .= $doc["content"];
            }
            return $output;
            


            Call it like such

            [!SnippetName?ids=`[*tvname*]`!]
              • 24495
              • 407 Posts
              Many thanks. Works great. Some styling (that’s what I can do myself) and it works perfect. So easy ... should learn more php ... rolleyes
                • 18397
                • 3,250 Posts
                I would have recommended Ditto which requires no PHP knowledge but it can’t sort based on the order of the IDs provided (yet).
                  • 6726
                  • 7,075 Posts
                  Heliotrope will tell me if I am wrong but maybe have a look at tvEditor too... (sorry, that’s in french)
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l'outil id
                    • 24495
                    • 407 Posts
                    Don’t like the tvEditor this time because you must change the ditto class. I think we should NOT change any snippets code/core code if a solution can be done by an other individual snippet. By heavy changing codes any upgrade of modx can run in errors. Maybe it works anytime without hacking codes.

                    @Mark: Ditto would be THE solution if it can handle IDs of documents and not only folders. In this case startID could be filled by the TV containing the IDs. ... wait ... could be done with Ditto 2? Must upgrade and test. And I can use templates for the output! And many more ... Thanks for the push to the right way grin
                      • 18397
                      • 3,250 Posts
                      Ditto 2 can with &documents, however the documents will not be returned in the order provided but by the order of &sortBy which can be set to any MODx field or TV. I’m working on a mode where Ditto will keep the order of the IDs provided...