We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    SOLUTION IN NEXT REPLY

    I know I can use ditto to populate a form
    is it also posible to use ditto to populate the report?
    or atleast gt the names from the form placed in the report?

    this is my idea:

    I want to make an ordering form for products, the form (products in the fom) are seperate pages that can be made and changed by the webmaster
    dito template would be somthing like this:
    [+longtitle+]<input type="text" name="[+description+]"><br />
    


    as you can see I can not ceate a report chunk because I do not know the names of the field beforehand.

    but if I could run ditto in the report with this tpl:
    [+longtitle+] = [+[+description+]+]<br />
    


    that this could work maybe (maybe the double [+ is a problem)

    but I can not run ditto in report for its not parsed in modx as a document would be.

    please let me know if anyone know a good way.

    Ok I managed to get the above working exept the [+longtitle+] = [+[+description+]+]
    part

    I think ditto strips the outer [++]

    so the report ditto is also working but no value’s

    I am so close




    Dimmy
      follow me on twitter: @dimmy01
      • 7455
      • 2,204 Posts
      YES!!!

      I did it
      here it comes:

      I created the folloing event snippet for efom:
      <?php
      function DittoEformEvent(&$fields, &$templates){
         global $modx;
      
      // get the form template and fill it with ditto generated values
      if(isset($templates['tpl'])){
      
          $ditto_params = array(
            'parents' => '67',
            'tpl' => 'ditto_sint_tpl',
            'language' => 'nederlands',
            'total' => 'all',
            'sortBy' => 'menuindex',
            'sortDir' => 'ASC' ,
            'summarize' => 'all'
         );
         
         $templates['tpl'] = str_replace('[+ditto_placeholder+]',$modx->runsnippet('Ditto',$ditto_params),$templates['tpl']);
         }
      
      //get the report and fill it with ditto generate custom placeholders
      
      if(isset($templates['report'])){
         $ditto_sint_params = array(
            'parents' => '67',
            'tpl' => 'ditto_sintreport_tpl',
            'language' => 'nederlands',
            'total' => 'all',
            'sortBy' => 'menuindex',
            'sortDir' => 'ASC' ,
            'summarize' => 'all'
         );
         
      $templates['report'] = str_replace('[+ditto_placeholder+]',$modx->runsnippet('Ditto',$ditto_sint_params),$templates['report']);
      $templates['report'] = str_replace( array('((','))'), array('[+','+]'),$templates['report']);
      }
      
         return true;
      }
      ?>
      


      then I made 2 chunks for ditto: "ditto_sint_tpl"
      <label>[+longtitle+]</label><input type="text" name="[+description+]"><br />
      


      then I made 2 chunks for ditto: "ditto_sintreport_tpl"
      [+longtitle+] = (([+description+]))<br />
      


      and we need a eform tpl that in my case only has this:
       <p><span style="color:#333;">[+validationmessage+]</span></p>
      <form name="sintbestelform" method="post" action="">
          <input type="hidden" name="formid" value="sintbestelform" /><br />
      [+ditto_placeholder+]
      <input type="submit" value ="submit" name="versturen" /><br />
      </form>
      


      and a report that is not more then:
      [+ditto_placeholder+]


      and the eform call:
      [!DittoEformEvent!]  [!eForm? &eFormOnBeforeFormParse=`DittoEformEvent`  &language=`nederlands` &formid=`sintbestelform` &to=`[email protected]`&fromname=`dimmy` &from=`[email protected]` &replyto=`[email protected]` &tpl=`eformSintTpl`  &report=`eformSintReportTpl` &subject=`Sint bestelling vanaf de website`!] 
      


      this is only my test setup and can be made as big as you like.

      Dimmy
        follow me on twitter: @dimmy01
        • 7455
        • 2,204 Posts
        Let me know if you could use this and maybe if its wiki worthy
          follow me on twitter: @dimmy01
          • 20413
          • 2,877 Posts
          I bookmarked this in my AWESOME category! cool
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 3749
            • 24,544 Posts
            That’s fantastic Dimmy. I think it would be a great addition to the Wiki.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
            • nice
                palma non sine pulvere
                • 33238
                • 388 Posts
                Dimmy, 4 Years Ago and this still working like PERFECT!!!!

                THAAAAANK YOU VERY MUCH MY FRIEND!!!! laugh

                this save my life.
                  --
                  ysanmiguel.com