We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    Maybe a bit confusing topic title but this is what I want.

    I am building a pdf creator that creates a pdf from a page. but with a custom layout.
    so I grab document fields like this:

                   $doc_id = $_GET['docid'];
    		$doc_id = isset($doc_id) ? $doc_id : $modx->documentIdentifier;
    		$document = $modx->getDocument($doc_id);
                    $pagetitle = $document['pagetitle'];
                    $introtext = $document['introtext'];
                    $content = $document['content'];
    


    That works fine BUT the content of the fields is not parsed its just the raw data from the database.

    I need the content to be parsed so that snippet cals and chunks are also parsed.
    I tryed :
    $content = $modx->documentContent( $doc_id );
    and
    $content = $modx->documentOutput($modx->documentContent( $doc_id ));

    but that also gave me raw database output

    any one knows how to trigger t he parser to pars content this way?

    would be great

    Dimmy
      follow me on twitter: @dimmy01
      • 4172
      • 5,888 Posts
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 19119
        • 22 Posts
        I’ve you tried the method $modx->parseDocumentSource()

        Document : /manager/includes/document.parser.class.inc.php line 970
        <?php
        /**
         * name: parseDocumentSource - used by parser
         * desc: return document source aftering parsing tvs, snippets, chunks, etc.
         */
        function parseDocumentSource($source) ...
        ?>
          • 7455
          • 2,204 Posts
          @mephissto: Nope tha did not do the trick ider i tryed this:
          $content = $modx->parseDocumentSource($document[’content’]);

          i get raw unparsed data.

          @Bruno17: I tryed that but somhow it did not do the trick because i do not want a blank template.
          so i tryed a variation of your id by dooing the foloing:
                  $url = $modx->makeUrl("147", '', '', 'full')."?docId=".$doc_id;
                  $content = file_get_contents($url); 
          

          one page 147 I have a snippet called getcontent:
          <?php
          if(isset($_GET['docId'])){
                                $doc_id = $_GET['docId'];
                                $document = $modx->getDocument($doc_id);
                                $content = $document['content'];
          }else{
                                $content = "Sorry no id";
          }
          return $content;
          ?>
          


          when I call that page from the browser direct then the page is parsed and i see parsed content somehow this does not work when i call it from the php file.
          if I type some plain text in doc id147 contentfield then I see that plain text.

          mm maybe I know what the problem is... the page is protected and apache (file_get_contents() ) is not logged in.
          mm big problem...
            follow me on twitter: @dimmy01