We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43702
    • 2 Posts
    Is there any way how to get a full static html source of specific documents? Some API or plugin?
      • 10208 ☆ A M B ☆
      • 1,780 Posts
      I could be wrong, but I think you can use the includeFile snippet (we used to have to use this for static files before 2.2.0).

      Repurpose the following for Evo tags of course.

      http://rtfm.modx.com/display/revolution20/Snippets
      Write your Snippets outside of MODx.

      As of 2.2.0, you can simply add a "static" Snippet: just reference the static file.

      Pre 2.2.0, it's still pretty easy to do - just create an 'include' snippet, but make its content be this:
      	
      if (file_exists($file)) {
         $o = include $file;
      } else { $o = 'File not found at: '.$file; }
      return $o;
      

      You can use the include snippet on a page like such:
      [[!include? &file=`/absolute/path/to/my/snippet.php`]]


      And run your Snippets externally while you develop them!

      Then you can test them to make sure they work (e.g. on the bash command line, you can use the command php -l my_script.php to check the script for syntax errors). Depending on your environment, you may also get some useful error messages to help you with debugging. Copy and paste the code into MODx only when you're sure it's working.

      Remember that a snippet in a file on your web site can be executed by anyone with a web browser, so don't leave them there on a live site unless you've placed the snippet code outside the web root so the file can't be accessed via the web. In MODx Revolution, you can put the snippet files under the core directory and move the entire directory outside the web root. You can also put a test in the snippet that makes it exit if it's not running inside MODx, but it's safest just to move the file or paste the code into a snippet in the Manager and delete the file.

        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 13226
        • 953 Posts
        Quote from: leblos at May 10, 2013, 02:46 PM
        Is there any way how to get a full static html source of specific documents? Some API or plugin?

        I think you need to be a little more precise with your question:

        What are you trying to do exactly:

        1) pull a static html file into a pre-defined page
        2) import a static file into the file system i.e as a page in the tree
        3) view the rendered source code of a page when visited in a browser
        4) export a page previously created in the manager

        For whats its worth, if you want "4" you can export the whole site using the backup tools in the manager:

        Tab "tools" => "Export Static HTML"
          • 3749
          • 24,544 Posts
          If I'm understanding you, you want this: http://wiki.modxcms.com/index.php/Export_static_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