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

    I’m creating an snippet and now I need to get the plain content html from an resource I created , I tried some things with getDocument but can’t get it working.

    Does anyone know how to solve this issue?

    Kind regards,
    Boyd

    edit: Excuse me for placing this topic in the wrong forum
      • 17422
      • 225 Posts
      hi,

      have you find the solution ?

      i want to get plain html of a resource in snippet.

      Laurent
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        That depends on which version of MODx you are using. For Evo (1.0.x) use $modx->getDocument(id, ’content’).

        http://wiki.modxcms.com/index.php/API:getDocument
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 17422
          • 225 Posts
          i use modx revo.

          i think found the solution with php code

          $data=null;
          $url = $modx->makeUrl($pageID, '', '', 'full');
          if($http= fopen($url,"r")){
          while(!feof($http)){
          $data .=fgets($http,1024);        
          }
          fclose($http);
          }
          preg_match_all('/(<div id="container">)(\W.*)(<\/div>.<div id="footer_top_border")/imsU',$data,$result);
          foreach($result[2] as $contenu){
          echo $contenu;        
          }
          

            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Ah, you want the complete, parsed page. That’s another matter altogether.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 17422
              • 225 Posts
              yes,

              I try to retrieve the contents of a div to display it via javascript ($.post)

                • 17422
                • 225 Posts
                i found.

                i add a comment html tag in my code html and now
                preg_match_all('/(<!--DEBUTCONTENEUR-->)(\W.*)(<!--FINCONTENEUR-->)/imsU',$data,$result);
                foreach($result[2] as $contenu){
                echo $contenu;        
                }