We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Try altering the snippet so it doesn’t return the result of the include and check your paths generated in your file to make sure it can find the styling based on the root of your site
      • 25762
      • 67 Posts
      My bad about return value; duh. However, removing it didn’t make a difference (e.g., the HTLM content displayed and the javascript executes its functions but the styling is trashed). Conversely, hard-adding a ’1’ to the original file after </html> doesn’t prevent expected execution/styling when invoking the stored file from the browser status line.

      I don’t think this should be a path issue. The javascript executes the styles entirely inline within the file. I have considered separating out the styles into a classic template, but this would be undesirable for reasons too detailed to go into here. My theory is that since the file was uploaded correctly to ModX and runs self-contained when invoked directly, there should be a way to pass it through ModX transparently.

      I am wondering whether ModX does any hidden processing when passing this file through the snippet?

      Understanding you may not want to bother at this point, let me point at the code itself (a copy outside of ModX in this case):
      http://russlipton.com/empty.html

      For any lurkers, what I am trying to do is use ModX as a wrapper for running instances of Tiddlywiki:
      http://www.tiddlywiki.com

      This would be most cool since Tiddlywiki currently lacks a standard server adaptation and I could foresee a fascinating synergy between it and ModX.

      .... I’ll keep at it.
        • 29635
        • 361 Posts
        I was getting the same ’1’ issue, where a ’1’ would be output right after the included file output. Quite odd. Fixed with this:
        // <?php // INCLUDE snippet
        
        $file= isset ($file)? $modx->config['base_path'] . $file: '';
        if ($file && file_exists($file)) {
            // return include($file);
            include "$file";
            return '';
        }
        $modx->sendErrorPage();

        Hopefully that helps some PHP-challenged folks like me.
        -Brett
          Need MODx Ecommerce? Try FoxyCart!
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          The "1" is the result of the include() function returning a success value (true or false). So if your snippet is returning the include function, the function does its thing (including the file) plus its success value. That’s why making the include() call then returning nothing gets rid of the "1".

          For example:
          $result = include "myfile.txt";
          echo $result;
          

          will display 1 if the file was successfully included.

          http://il.php.net/include/
            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