We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16732
    • 592 Posts
    I have read the great shaun’s tutorials but I did not find the answer to my problem.

    Always in the hope of understanding the philosophy of Revolution wink, I try to convert my old plugin "footnote" but I don’t find (maybe because I don’t know where to look at) the equivalent of
    &$modx->documentObject[’content’];
    I used with the 096

    A short tutorial with old and new syntax will be fabulous.

    Thx


      • 28215
      • 4,149 Posts
      Quote from: laurentc at Jul 17, 2008, 01:05 PM

      Always in the hope of understanding the philosophy of Revolution wink, I try to convert my old plugin "footnote" but I don’t find (maybe because I don’t know where to look at) the equivalent of
      &$modx->documentObject[’content’];
      I used with the 096

      Probably how I would do it:

      $resource = $modx->getObject('modDocument',$modx->resourceIdentifier);
      echo $resource->content;
      


      I’ll let Jason correct me if I’m wrong. tongue
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 16732
        • 592 Posts
        Hi shaun,

        thank you for your answer but in fact I have something like that :

        <?php
        $e = &$modx->Event; 
        switch ($e->name) { 
                case "OnLoadWebDocument":	
                      $o = &$modx->documentObject['content'];                
        	      $npp = "jkjkjk";
                      $o .=  $npp;
        	
                break;
                default :
                    return;
                break;
        
        }
        ?>
         

        here the plugin should had the string "jkjkjk" at the end of the content ... how can I do that with Revolution ?
        • here the plugin should had the string "jkjkjk" at the end of the content ... how can I do that with Revolution ?
          Hi laurentc, just tried that sample plugin in my local install of Revolution and it works as intended - are you having issues with the above code?
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
          • Quote from: garryn at Jul 17, 2008, 02:12 PM

            here the plugin should had the string "jkjkjk" at the end of the content ... how can I do that with Revolution ?
            Hi laurentc, just tried that sample plugin in my local install of Revolution and it works as intended - are you having issues with the above code?

            That should work, though the documentObject is deprecated in Revolution, and will be removed in a minor release moving forward. The proper way to do this now is actually much more concise:

            <?php
            switch ($modx->event->name) {
                    case "OnLoadWebDocument":
                        $modx->resource->content .= 'jkjkjk';
                        break;
                    default:
                        break;
            }
            ?>
              • 16732
              • 592 Posts
              Quote from: garryn at Jul 17, 2008, 02:12 PM

              here the plugin should had the string "jkjkjk" at the end of the content ... how can I do that with Revolution ?
              Hi laurentc, just tried that sample plugin in my local install of Revolution and it works as intended - are you having issues with the above code?

              Shame on me I forgot to put [[+content]] in my template embarrassed embarrassed

              Thanks Jason for the proper way to do.

              And many thanks to all of you for your help
                • 16732
                • 592 Posts
                Hi Jason,

                I have tested the way you told me to use but this does not work for me :

                $o = $modx->resource->content;

                I have to use the old one

                $o = &$modx->documentObject[’content’];

                Here my working plugin code :

                <?php

                switch ($modx->event->name) {
                case "OnLoadWebDocument":

                $o = &$modx->documentObject[’content’];

                // récupération de tous les Npp {-NPP-}
                if(preg_match_all( ’~\{-(.*?)\-\}~’ , $o, $tbl_npp)){

                $page= ’index.php?id=’.$resource->id;
                if($modx->config[’friendly_urls’] == 1){$page = $modx->resource->alias ;}else {$page= ’index.php?id=’.$modx->resource->id ;}

                $tbl_npp1 = array_unique($tbl_npp[0]);
                for($i=0;$i<count($tbl_npp1);$i++) {
                $numbNote = $i+1;
                $o = str_replace($tbl_npp1[$i],’<sup><a href="’. $page.’#nb’.$numbNote.’" name="nh’.$numbNote.’">’.($i+1).’</a></sup>’,$o);
                }

                $npp .= "

                --- Notes ---";
                for($i=0;$i<count($tbl_npp1);$i++) {
                $numbNote = $i+1;
                $npp .= ’
                [<a href="’. $page.’#nh’.$numbNote.’" name="nb’.$numbNote.’">’.($i+1).’</a>] ’.substr(substr($tbl_npp1[$i],2),0,strlen($tbl_npp1[$i])-4);

                }

                $o .= $npp;


                }
                else{
                return;
                }

                break;
                default :

                break;

                }
                ?>

                Maybe I missed something embarrassed
                  • 16732
                  • 592 Posts
                  I actually missed something embarrassed...

                  with this it’s working : $o = &$modx->resource->content;

                    • 16732
                    • 592 Posts
                    Just a question, It’is possible to make plugin packages with modx-2.0.0-alpha-2-sdk ?

                    I tryed to use the Shaun tutorial and use the modPlugin class key to make the package but when I make an install of my plugin package I have 2 problems :
                    1) The plugin code seems to be past but not the event
                    3) My files are not duplicate in the assets directory :
                    I use the SVN component structure with a myplugin/trunk/assets/elements/plugins/ directory where I put my myplugin.plugin.php file
                    and a myplugin/trunk/assets/elements/plugins/images directory ... with images.

                    I have created a resolver with :
                    Type : file
                    Name : myplugin
                    Source : c:\wamp\www\myplugin\trunk\assets
                    Traget : return MODX_ASSETS_PATH . ’plugins/’;

                    But after the installation I have no "myplugin" directory in assets

                    What I’m doing in a wrong way ? huh








                    • Can you post the script you used to make the plugin package? In order to install events, you need a resolver script like the one for TinyMCE.