We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10165
    • 129 Posts
    I have a tv to select associated products - A listbox-multiple that adds IDs with dividers. How do I get my ditto to list these? Should I be able to use as is or should I alter the tv settings to make it output comma separated?

    many thanks
      • 4172
      • 5,888 Posts
      if you want to use &documents=`[*yourTV*]` then you need commaseperated TV-output.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 2819
        • 30 Posts
        So to make a relation between products :

        You (already?) make/made a TV in the ’product’ template ..
        You make it the type of TV you want for instance : a listbox / multiple or a list of checkboxes ...

        What you do then is put something like this in the "Input Option Values: "

        @EVAL return($modx->runSnippet(’Ditto’, array(’parents’=>’79’, ’depth’=>’1’, ’tpl’=>’@CODE:[+longtitle+]==[+id+]||’, ’tplLast’=>’@CODE:[+longtitle+]==[+id+]’, ’display’=>’all’, ’sortBy’=>’pagetitle’, ’sortDir’=>’ASC’)));


        So this will list all documents (products) under ID 79 and render it in the for checkboxes/ multiple select lists required format :
        option1==value1||option2==value2||option3==value3
        http://svn.modxcms.com/docs/display/MODx096/Creating+a+Template+Variable

        This way the list you can pick from is always up to date ...

        Also (this is important for showing the related products!) you should select the right widget for this TV : it is ’delimeted list’ and the delimiter value the "," ...

        On the product page in the ’related products’ box you would call [[Ditto? &documents=`[*relatedProdTV*]`]]

        due to the widget [*relatedProdTV*] contains something like 85,98,103 which is exactly the documents parameter for the ditto call takes in ..

        Good luck !
          • 10165
          • 129 Posts
          thanks guys, I’ve made it delimited comma sep with the widget and it works fine

          many thanks
            • 10165
            • 129 Posts
            thanks bartnelis - that method of using ditto in the input is very interesting - I hadn’t thought of using that before - that opens up a whole new set of possiblities!.. currently I had :

            @EVAL return $modx->runSnippet(’Quill’,array(’parent’=>’container-name-here’,’depth’=>’3’,’mode’=>’list’,’showPublishedOnly’=>’1’));

            thanks again
              • 2819
              • 30 Posts
              Actually,

              I think quill is easier for most applications ... (it did’nt exist when i came up with this method) ...
              on the other hand : if you use ditto you can use filters and/or tags ...

              for instance &filter=`template,4,1` &parents=`79` will list all product templates(template id=4) under parent id79 ... and not show regular document (eg. template id=1) etc ...

              also you have more freedom in defining what you show : [+lastname+], [+firstname+]==[+id+] for contact persons (with tv’s firstname & lastname) for instance ....