We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33968
    • 863 Posts
    How might I, in a snippet inserted into a Ditto list template, add the value of a TV from the current document to that of the listed document?

    Let’s say the tv I want to sum is called [*tvPrice*].

    I’m thinking the Ditto tpl would be something like:

    Current Item plus [+pagetitle+] price: [[SumTVs? &tv=`tvPrice` &docs=`[*id*],[+id+]`]]
    

    Where:
    - [[SumTVs]] is the snippet containing php code to add the two TVs together
    - tvPrice is the tv we want to draw data from
    - [*id*] is the current document id
    - [+id+] is the listed document id

    Apparently the math can be done via a fairly straightforward mySql statement but I’m not sure how to begin. I haven’t created a snippet before and know very little php rolleyes
    I’m willing to give it a go if anyone is willing to give me some tips on how to get started. I guess it could be quite a useful little snippet for product bundling, etc

    As always, thanks in advance for your help!

    Luke
      • 4172
      • 5,888 Posts
      do you want to sum all listet resources together or do you only want to show the sum of current listed resource + main-resource?

      the second can you do with phx:
      [+tvPrice:math=`?+[*tvPrice*]`+]
      

        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 33968
        • 863 Posts
        Haha, great!! That’s exactly what I wanted, thanks for your help laugh