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
    I was wondering if it is possible to only show parts in the report if the field is filled in.

    would be nice if phx could be used in the report something like this:

    [+fax:isnot=``:then=`fax: [+fax+]`+]

    that would give so much more flexibility in how to use the report,

    in my case I need to copy and past address etc into Indesign to use but I do not want to remove lines that I do not need.

    sometimes a client only wants his address and phone number on his product. and another wants the whole list of address, phone, city, email, www etc.

    or could a event be used to accomplish this?
    is it possible to add stuff to the report chunk while processing?

    Dimmy

      follow me on twitter: @dimmy01
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Check the onBeforeMailSent event; I believe you have access to all the fields as well as the report template in that event.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 7455
        • 2,204 Posts
        where can I find the documentation on onBeforeMailSent or do I have to dive into the code to see what it does?

        here its explained: http://svn.modxcms.com/crucible/browse/~raw,r=9/modx-components/eform/docs/eform_example_events.htm
        but it only say’s that $fields is passed to that event

        (phx would still be a great option)
          follow me on twitter: @dimmy01
          • 7231
          • 4,205 Posts
          (phx would still be a great option)
          Does phx play nice with eForm?
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 7455
            • 2,204 Posts
            Quote from: dev_cw at Feb 20, 2008, 06:20 AM

            (phx would still be a great option)
            Does phx play nice with eForm?

            no but it should

            life is so much easier with phx
              follow me on twitter: @dimmy01
              • 7455
              • 2,204 Posts
              ok i tryed this to test:
              <?php
              function populatereport(&$report) {
              print_r($report);
              }
              return;
              ?>
              

              and it returned the same array as the $fields array.
              looks like $report is not usable?


              mm maybe that this would work?

              get the value of the fields see if they are filled in ifso replace the value with "fax: value"
              would that work?

                follow me on twitter: @dimmy01
                • 7455
                • 2,204 Posts
                ok this works:
                <?php
                function populatereport( &$fields ){
                		if($fields['slogan']){$fields['slogan']= "Slogan:".$fields['slogan'];}
                		if($fields['fax']){$fields['fax']= "Fax number:".$fields['fax'];}
                		return true;
                	}
                ?>
                


                would be even better if we could walk tru the fields and the if the field is filled in grab the name of the field and us that as the prefix for the value something like this:

                $fields[’fieldvalue’]=$fields[’fieldname’].": ".$fields[’fieldname’];

                somehow walk true the fields and see if not empty then do the above.
                that would work, now I need to go to php.net to see how (or maybe some of you php guru’s can whip it by hart?)

                Dimmy
                  follow me on twitter: @dimmy01
                  • 7455
                  • 2,204 Posts
                  ok here it goes:

                  <?php
                  function populatereport( &$fields ){
                  
                  foreach ($fields as $key => $value) {
                  		if($fields[$key]){$fields[$key]= $key.": ".$fields[$key];}
                  }
                  		return true;
                  	}
                  ?>
                  


                  so simple but working great for me

                  so if a field is filled then the placeholder will get a prefix with the name of the field.

                  <input type="text" name="faxnumber" /> wil result in this when filled in faxnumber: 1234567890
                  this way you can have a clean email

                  Dimmy
                    follow me on twitter: @dimmy01
                    • 36416
                    • 589 Posts
                    Quote from: Dimmy at Feb 20, 2008, 06:27 AM

                    Quote from: dev_cw at Feb 20, 2008, 06:20 AM

                    Does phx play nice with eForm?
                    no but it should
                    life is so much easier with phx

                    This worked for me in form templates:
                    http://modxcms.com/forums/index.php/topic,19011.0.html
                      • 7455
                      • 2,204 Posts
                      Nice I see that I saw this before but just forgot this. I will try this thank you
                        follow me on twitter: @dimmy01