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

    Trying to get placeholders to be replaced in the automessage chunk and struggling. I am doing a call fron a snippet like this
    $output   =  $modx->runSnippet(
                 "eForm",array(
                    'eFormOnBeforeMailSent' => 'process',
                    'automessage' => 'chunk'
                ));
    

    Then the 'process' function looks like this
    function process(&$fields){
        some stuff here();
     $fields['link'] = '<a href="[(site_url)][~115~]">follow the link</a>';  
        return true;
    }
    


    and finally in the automessage chunk, I have somethign like this
    You can [+link+] and do something
    


    The problem is that this [(site_url)][~115~] does not get replaced. The placeholder in the chunk does, but it's no good as I just a link to [(site_url)][~115~], not the right link. Anyone know how can I get modx to process [(site_url)][~115~] to the proper url?

    Thanks!!
      • 16278
      • 928 Posts
      API makeUrl() should do the trick:

      function process(&$fields){
          global $modx;
          some stuff here();
      
       $fields['link'] = '<a href="' . $modx->makeUrl(115, '', '', 'full') . '">follow the link</a>'; 
          return true;
      }


      ;) KP
        • 37758
        • 73 Posts
        Ah yes, hadn't thought of that, all working now, thank you!