We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4971
    • 964 Posts
    I am trying to integrate my CRM (XRMS) contact form into my modx website.  It accepts input and places the customer info in the CRM and creates an activity (reply to the client) and creates an opportunity (client wants a service).

    The plugin from XRMS has four parts:

    1) the form which I just copied into the "Contacts" document in my site.  Works perfect.

    2) the processing script which is located in a subdirectory of XRMS in the same server as my site.  I do not touch that one.

    3) two functions for javascript validation.  I have placed that in the templates/mytpl/js directory of my site and created a chunk with the <script> on it, and then placed a call to the chunk in the "Extra Header" template variable (puts extra calls in the header of a page for javascript, extra css and the like)  Works fine.

    4) the last part is the connection to the XRMS application.  It includes all the functions for connection to the DB and other stuff to input the info into the appropriate places in the CRM.  This snippet looks as follows:

    <?php
    require_once('../../include-locations.inc');
    require_once($include_directory . 'vars.php');
    require_once($include_directory . 'utils-interface.php');
    require_once($include_directory . 'adodb/adodb.inc.php');
    require_once($include_directory . 'utils-accounting.php');
    
    $con = &adonewconnection($xrms_db_dbtype);
    $con->connect($xrms_db_server, $xrms_db_username, $xrms_db_password, $xrms_db_dbname);
    //$con->debug = 1;
    ?>
    


    I have replaced the $include_directory variable with all the path to the files...
    The XRMS plugin loads (puts) all these code before the <html> of the document, how can I do the same?

    I have tried placing the snippet at the very top of my content area, but it does not work.

    I don’t want to place it in the template, because it is only going to be used in this page, not in the other 50...

    Any help will be appreciated...
    Carlos
      Website: www.mercologia.com
      MODX Revo Tutorials:  www.modxperience.com

      MODX Professional Partner
      • 33372
      • 1,611 Posts
      So you’re saying that you’re seeing the snippet code in your HTML output (i.e., it’s not being executed)? If so, then try changing the way that you’re calling the snippet (if it’s currently called cached [[...]], made it uncached [!...!], or the reverse). I find that this occasionally happens to me when I have an uncached snippet call on an uncached page, and making the snippet call cached instead fixes it.
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 4971
        • 964 Posts
        Nope, I get a blank page using the snippet call cached or uncached...

        so... I am thinking that I am putting the snippet in the wrong place, in the plugin  the php code comes before the <html> tag.  BUT I do not know how to put it there for just this page!

        then maybe it will work... the form seems to be working fine, but it does not send anything to the DB (obviously) because the connection to the DB is not done... help!
          Website: www.mercologia.com
          MODX Revo Tutorials:  www.modxperience.com

          MODX Professional Partner
          • 33372
          • 1,611 Posts
          You’re not getting a require error or anything like that?
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
          • Your snippet doesn’t return anything. AS far as I know and from experience you need to return a value, string or array to the snippet call. BUT you should be getting an eval() error instead of showing the snippet as raw text.

            I’m no php expert but I think something like this would work:
            <?php
            $output = '';
            $output .= "require_once('../../include-locations.inc')";
            $output .= "require_once($include_directory . 'vars.php')";
            $output .= "require_once($include_directory . 'utils-interface.php')";
            $output .= "require_once($include_directory . 'adodb/adodb.inc.php')";
            $output .= "require_once($include_directory . 'utils-accounting.php')";
            
            $con = &adonewconnection($xrms_db_dbtype);
            $con->connect($xrms_db_server, $xrms_db_username, $xrms_db_password, $xrms_db_dbname);
            //$con->debug = 1;
            
            return $output;
            ?>


            I am still not convinced that this will work. Does this application have an API and or wrapper class for php? Typically CRMs don’t make it so hard to insert contact data collected from websites. SugarCRM, vTiger, Salesforce, Goldmine, Highrise all make it pretty easy to insert contacts directly to your CRM via API and in most cases a wrapper class.
              Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
              • 4971
              • 964 Posts
              @ZAP:  nope, nothing... but I think is what Jay mentioned... it is not being parsed...

              Good point Jay

              I was playing putting a TV in my template at the top and then placing the code right in the TV on the page,
              but it just shows the code without parsing it...

              let me try your idea of the $output, even though, as you mention, we still have the two last lines....

              man, I should have read Susan’s tutorials when she made them available!!!

              This is the way to use the API, the API functions are in the require_once files...
              I just have to include them... smiley and that is where my problems is....

              I do not know how to make that bunch of php to run at the beginning of my page...
                Website: www.mercologia.com
                MODX Revo Tutorials:  www.modxperience.com

                MODX Professional Partner