We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18397
    • 3,250 Posts
    How would I go about writing a plugin to add a bit of html to the bottom of the add/edit content page?
      • 32963
      • 1,732 Posts
      Hi Mark,

      These are the events for the manager document/content page:
      OnDocFormPrerender
      OnDocFormRender
      OnBeforeDocFormSave
      OnDocFormSave
      OnBeforeDocFormDelete
      OnDocFormDelete

      To diplay some text inside the page use:
      OnDocFormRender

      Here’s an example:
      $e = & $modx->Event;
      switch ($e->name) {
      	case "OnDocFormRender":
      		$html = "
      			<div class='sectionHeader'><img src='media/images/misc/dot.gif' alt='.' /> My Box</div>
      			<div class='sectionBody'>
      			<input type='checkbox' name='someoption' value='1' />
      			Some text here
      			</div>
      		";
      		$e->output($html);
      }

        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 18397
        • 3,250 Posts
        Ok, now how would I do the following?

        Say that if that checkbox is checked, initiate an action contained within a module AFTER THE PAGE IS SAVED.
          • 32963
          • 1,732 Posts
          Quote from: Mark at Nov 07, 2005, 05:24 AM

          Ok, now how would I do the following?

          Say that if that checkbox is checked, initiate an action contained within a module AFTER THE PAGE IS SAVED.

          Well (currentlly) you can’t invoke a module from within the API. But you can include and external php file with the code to be executed. For example you could store parts of the module as an include file.

            xWisdom
            www.xwisdomhtml.com
            The fear of the Lord is the beginning of wisdom:
            MODx Co-Founder - Create and do more with less.
            • 18397
            • 3,250 Posts
            Ok, simple enough.So now the question reads:

            Say that if that checkbox is checked, initiate an action contained within a php file AFTER THE PAGE IS SAVED.
              • 32963
              • 1,732 Posts
              Give this a try:

              case "OnDocFormSave":
              	include_once "assets/modules/mymod/file.php";
              	if($_POST['someoption']=='1') {
              		// do something		
              	}
              	break;


                xWisdom
                www.xwisdomhtml.com
                The fear of the Lord is the beginning of wisdom:
                MODx Co-Founder - Create and do more with less.
                • 18397
                • 3,250 Posts
                How do you call a RTE from within a module?

                I tried:

                $o = '<div class="MODX_RichTextWidget"><textarea id="ta" name="ta" style="width: 100%; height: 400px">';
                $o.= '</textarea></div>';
                echo $o;
                $modx->invokeEvent("OnRichTextEditorInit",array("ta"));
                


                But to no avail.
                  • 32963
                  • 1,732 Posts
                  you might want to try and fo this:

                  $replace_richtexteditor = array("ta");
                  if(is_array($replace_richtexteditor)) {
                  	// invoke OnRichTextEditorInit event
                  	$evtOut = $modx->invokeEvent("OnRichTextEditorInit",
                  									array(
                  										editor 		=> $modx->config['which_editor'],
                  										elements	=> $replace_richtexteditor
                  									));
                  	if(is_array($evtOut)) echo implode("",$evtOut);				
                  }
                    xWisdom
                    www.xwisdomhtml.com
                    The fear of the Lord is the beginning of wisdom:
                    MODx Co-Founder - Create and do more with less.
                    • 18397
                    • 3,250 Posts
                    I get the following error with that code:

                    Use of undefined constant elements - assumed ’elements’
                      • 32963
                      • 1,732 Posts
                      Change to:

                      	$evtOut = $modx->invokeEvent("OnRichTextEditorInit",
                      									array(
                      										'editor' 		=> $modx->config['which_editor'],
                      										'elements'	=> $replace_richtexteditor
                      									));
                        xWisdom
                        www.xwisdomhtml.com
                        The fear of the Lord is the beginning of wisdom:
                        MODx Co-Founder - Create and do more with less.