We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40762
    • 54 Posts
    Hey all, I've been facing this problem for the past months when using modMail. I don't know if any of you ever had this but it seems that modMail gets processed asynchronously to the normal modx function. Lets say I populate the content with a chunk and in that chunk there is a snippet that needs to be run, I would say 60% of the time the process fails leaving empty space and sometime even unmodified placeholder.

    The issue is very inconsistent. With the same data I get different result.

    I would like to mention aswell, that when I send the content of the email in the error log, all the information gets processed normally.

    Thanks

    Mark
      Marc-Andre Audet
      • 3749
      • 24,544 Posts
      Are you getting the chunk with $modx->getChunk()? [ed. note: BobRay last edited this post 12 years, 6 months ago.]
        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
        • 40762
        • 54 Posts
        Yes I am actually
          Marc-Andre Audet
          • 3749
          • 24,544 Posts
          Normally all the tags in the chunk would be parsed during that operation, unless they're called uncached. In that case the processing of the tags is delayed until just before the page is rendered, which in your case never happens.

          You could try an extra processing step after the getChunk() call.

          $content = $modx->getChunk("SomeChunk");
          
          $tempChunk = $modx->newObject('modChunk');
          $tempChunk->setContent($content);
          $tempChunk->setCacheable(false);
          $tempChunk->process();
          $content = $tempChunk->getContent();

            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
            • 40762
            • 54 Posts
            Actually, I am currently setting up a custom form / auto responder for one of my client and I want to use this technique to grasp the auto responder content and process the custom field taken from the form.

            I have also tried this and it s not working either.

            I am suspecting it is a problem with modMail. SMTP is not turned on aswell.
              Marc-Andre Audet
              • 3749
              • 24,544 Posts
              I can almost guarantee that the problem is not with modMail. modMail will send whatever you give it. It does no parsing at all, so you need to make sure all parsing of tags is done before handing off the content to modMail.

                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
                • 40762
                • 54 Posts
                Let me review if I pass my associative array right but I feel that modMail might fire before without waiting for my snippet to fully parse my chunks.
                  Marc-Andre Audet
                  • 40762
                  • 54 Posts
                  // Create the temporary chunk
                  $uniqid = uniqid();
                  $chunkContent = $modx->newObject('modChunk', array('name' => "{tmp}-{$uniqid}"));
                  $chunkContent->setCacheable(false);
                  
                  
                  $chunkContent->setContent($autoResponder['content']);
                  
                  $o['content']=$chunkContent->process($quote);
                  


                  $quote being an associative array.

                  does this make sense?
                  I got the code from another tread it should make sense because when I trow $o['content'] in the log I get exactly what I am expecting. I am running snippets in this "custom chunk".

                  Its not the first time that this occurs to me. I have also tried the sleep() function but with no success.

                  Maybe I could cache the processed chunk and have a hook when the chunk is save to have it mailed to the person concerned.

                  Anyway I am still going to look for potential culprit.

                  For now good night

                  Mark
                    Marc-Andre Audet
                    • 40762
                    • 54 Posts
                    Ok! Hey all. I just want to apologize for the mislead debug. I finally found the problem which had nothing to do with modMail. Actually, I was passing my values through formit and as I was outputing my value in the the snippet placeholder they also got processed there!

                    So yes Bob it was a parsing error on my side.

                    Thanks and good day everybody
                      Marc-Andre Audet
                      • 3749
                      • 24,544 Posts
                      I'm glad you got it sorted. smiley
                        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