We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44437
    • 74 Posts
    Hey All,

    I was wondering how I can get the total sum of points stored within a migx tv?

    I have a migx tv that has 5 fields: 1 textbox, 1 date and 3 single list-box.

    The fieldnames for the 3 list-box are:

    • [[+race1]]
    • [[+race2]]
    • [[+race3]]
    and the Input Option Values are:
    1st==10||2nd=8||3rd==6||DQ==0


    I tried the code below within my getImageList call
    [[+race1:add=`[[+race2:add=`[[+race3]]`]]`]]
    but noticed that this won't get the total some of points.

    Any suggestions?

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      do you have that output-filter-combination in an inline-tpl (@CODE) or in a chunk?

      you might also try a snippet:

      $values = explode(',',$modx->getOption('values',$scriptProperties,'0'));
      
      $sum = 0;
      foreach ($values as $value){
          $sum += $value;
      }
      
      return $sum;
      [ed. note: Bruno17 last edited this post 11 years, 5 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 44437
        • 74 Posts
        I have output-filter-combination in a chunk. Is it possible to use a chunk as the Input Option Values for a tv which has the input type of number and within that chunk use getImageList calculate the total number of races?

        Also, the snippet example that you have provided, how does this works? Like

         [[totalpoint?
               &input=`[[!getImageList? &tvname=`myMIGXtv` &tpl=`@CODE:[[+race3]]`]]
        `]]
        
        


          • 4172
          • 5,888 Posts
          you would replace

          [[+race1:add=`[[+race2:add=`[[+race3]]`]]`]]


          with

          [[sum? &values=`[[+race1]],[[+race2]],[[+race3]]`]]
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 44437
            • 74 Posts
            Apologies for taking so long to reply. I got caught up on another project and just got back to this issue this week.

            Thanks Bruno for your suggestion. It works.