We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Does the full error message tell you what directory it's looking in? You could put math.txt there (or alter the code to provide the full path to math.txt).


    ------------------------------------------------------------------------------------------
    PLEASE, PLEASE specify the version of MODX you are using.
    MODX info for everyone: http://bobsguides.com/modx.html
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 40029
      • 52 Posts
      Hi,

      It's all about time and place, do not quite understand if you want to generate a pdf file in your call, or in the rendering of the page. in all cases there are dozens of ways to make this possible and even using MODx.
      I think, could use a technique with FURL enabled and get a call type
      <a href="dummyfile.pdf"> .. bla bla </ a>

      and so a "MODx plugin" can do all the work(example use to "handle event" in this case the plugin will be executed before any other code).

      I'm not sure, if you put the file, in the same place where the snippet is being executed, and in any case, this would be very dirty work, put the public files on the internal structure of MODx.

      The best thing you could debugging your code on a local machine,
      with zend studio, netbeans or another solution.
      But fortunately exist others efficient ways to get output at runtime identification.
      Such as whether you want to know the "dirname" current from a snippet before parsing, could use the statement (ONLY DEBUG PURPOSE!)

      exit(dirname(__FILE__)); 


      or post parsing a sentence, like:

      echo '<script>alert("'.dirname(__FILE__).'");</script>';


      note this is a very important development in the snippet,
      All MODx tags are evaluated in the final output from the recognition of text and not at runtime, this means that if you call an

      exit('[[++site_url]]');
      >> ['[ ++site_url ]']

      its output will not be interpreted, if left to go on a post parsing if then be evaluated.

      This can give you many problem if you use functions in external files that alter the execution flow of a snippet.

      If for example you create an external file called: dummy.php
      and placed inside , this code:

      <?php
      
      function dummyfunction($var)
      {
      	echo '<script>alert("'.$var.'");</script>';
      	exit();
      }


      *note "This is done in many library examples of treatment of output, or file streaming. Because in the example, you do not see this in a controlled setting, as in the case are running calls from within MODx."



      and then includes the file in your snippet and call the function without processing the tag

      require_once "dummy.php";
      
      dummyfunction('[[++site_url]]');
      


      will output this:
      >> ['[ ++site_url ]']

      and you should do weird things like this to process your "output":

      dummyfunction(preg_replace(array('/\[\[/','/\]\]/'),'',$modx->getParser()->processTag(array('','[[++site_url]]'))));
      


      >> http:// www.dummysite.com


      My advice is that if you are using MODx, try using the order of classes with native MODx MVC2 model, so may be more compatible with the security mechanisms of the system and will surely be easier to package your code to export to other facilities MODx.

      I am also curious to know, where you copy your file. "txt" and what was the call and from where the error is probably due to a wrong analysis of the runtime.


      Regards
        Developer of RTOS and Drivers
        Specializes in portability of BSD/Linux
        • 39929
        • 113 Posts
        thank you very much for the advices. I just made it to run my pdf. Unfortunately there is another problem. I have a document that has this link:

        <li><a href="[[!snippet]]" target="_blank">text here</a></li>
        


        I want to click this link first before I open mypdf. The problem is whenever I click my document, it automatically redirect me to mypdf. how is that?
          • 3749
          • 24,544 Posts
          The snippet will execute when MODX sees the snippet tag. Is the snippet redirecting the user to the pdf file?

          The snippet should just create the pdf file and return the path to it.


          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 3 months ago.]
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 39929
            • 113 Posts

            The snippet will execute when MODX sees the snippet tag.

            I see. So I just change or perhaps tweak a lil in my codes. Is there any way to do that? I want to click the link first before redirecting to mypdf.
              • 3749
              • 24,544 Posts
              Quote from: BobRay at Jul 11, 2012, 03:16 AM

              The snippet should just create the pdf file and return the path to it.

              I can't think of any other way to say it. wink



              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 39929
                • 113 Posts
                Anyway..I think I can handle it now. Thank you very much!