We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19388
    • 297 Posts
    Hello,
    I’m creating a basic plugin that generates an images with the title of the content when the content is saved, but I have a problem retrieving the parameters when the event ( OnDocFormSave ) is executed.
    Searching in modx website, wiki, api, forums and google I found how to get the ID but not the Page title.

    Can you tell me where is the pagetitle? Where is it documented? Because I cannot find that

    Thanks!

    EDITED: I solved that using $_POST[’pagetitle’] but, is this a good way? Can I do that using the API?

    Here is the code:

    $imagesFolder="/home/page/images/titulosNoticias/";
    $e = $modx->Event;
    
    $contentID=$e->params['id']; //It's OK
    $contentTitle=$e->params->documentObject['pagetitle'];  //Doesn't Work. 
    //$contentTitle=$e->params['pagetitle'];  //Doesn't Work too.
    
    $im = imagecreatefrompng($imagesFolder."vacio.png"); 
    $blue = imagecolorallocate($im, 0, 0, 124);
    imagettftext($im,20,1.5,71,51,$blue,$imagesFolder."DIEDIEDI.TTF",strtoupper($contentTitle));    
    
    imagesavealpha($im, true);
    
    imagepng($im,$imagesFolder."titulo_".$contentID.".png"); 
    imagedestroy($im);
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: mIDO at May 15, 2009, 10:33 AM

      EDITED: I solved that using $_POST[’pagetitle’] but, is this a good way? Can I do that using the API?
      That is the correct way, using the POST variables. There will be more API functions and features in Revo in this regard, but for 0.9.6.x, that’s your best approach.
        • 19388
        • 297 Posts
        Thanks for your reply, but I want to launch another question...
        What could be done if, for example, I want to do the same when a page is duplicated? There is no event for duplication. And, if the event OnDocFormSave were called I couldnt use the $_POST var. That is what happens now when I duplicate a content.
        Any idea?
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: mIDO at May 15, 2009, 12:47 PM

          Thanks for your reply, but I want to launch another question...
          What could be done if, for example, I want to do the same when a page is duplicated? There is no event for duplication. And, if the event OnDocFormSave were called I couldnt use the $_POST var. That is what happens now when I duplicate a content.
          Any idea?
          That is currently not a feature, but someone has already entered a ticket for some OnDuplicate events and many others to be added. Might consider voting for it and maybe it will get into the Evolution 1.0 release.
            • 19388
            • 297 Posts
            perfect laugh
            Thanks