We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2762
    • 1,198 Posts
    Is it possible to include a php file in a document? huh
      Free MODx Graphic resources and Templates www.tattoocms.it
      -----------------------------------------------------

      MODx IT  www.modx.it
      -----------------------------------------------------

      bubuna.com - Web & Multimedia Design
      • 32963
      • 1,732 Posts
      Quote from: banzai at Jun 27, 2005, 12:35 PM

      Is it possible to include a php file in a document? huh

      Sure you can.

      1) Create a TV called MyFile
      2) Inside the default value enter @EVAL include ’yourfile.php’;
      3) Save the TV
      4) Edit the document and add [*MyFile*] inside it’s content
      5) Save document

      That’s it!


        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 2762
        • 1,198 Posts
        Thank very much i’ll try it smiley
          Free MODx Graphic resources and Templates www.tattoocms.it
          -----------------------------------------------------

          MODx IT  www.modx.it
          -----------------------------------------------------

          bubuna.com - Web & Multimedia Design
          • 2762
          • 1,198 Posts
          ..included file appears in the top of the page sad
            Free MODx Graphic resources and Templates www.tattoocms.it
            -----------------------------------------------------

            MODx IT  www.modx.it
            -----------------------------------------------------

            bubuna.com - Web & Multimedia Design
            • 32963
            • 1,732 Posts
            Quote from: banzai at Jun 27, 2005, 01:07 PM

            ..included file appears in the top of the page sad

            Change the @EVAL to :

            @EVAL
            ob_start();
            include "yourfile.php";
            $rt = ob_get_content();
            ob_end_clean();
            return $rt;

              xWisdom
              www.xwisdomhtml.com
              The fear of the Lord is the beginning of wisdom:
              MODx Co-Founder - Create and do more with less.
              • 30517
              • 9 Posts
              Hi, I want to include a php file that uses another database and I get an error stating a table it uses doesn’t exist, plus another error about myssql_free-result..even though the later works perfectly in the other program which is in a folder inside the modx(root) folder. Basically I’m trying to call up the minicart that works with the shopping cart(other program).

              Any ideas are welcome.
              Tracyjs
                • 3749
                • 24,544 Posts
                Maybe I’m misunderstanding you, but why not put the php code in a snippet and include a call to that snippet in the document?
                  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
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: tracyjs at Jan 07, 2009, 11:35 PM

                  Hi, I want to include a php file that uses another database and I get an error stating a table it uses doesn’t exist, plus another error about myssql_free-result..even though the later works perfectly in the other program which is in a folder inside the modx(root) folder. Basically I’m trying to call up the minicart that works with the shopping cart(other program).
                  Typically this means that the include is hijacking the mysql connection that MODx is already using. The external script would have to be modified to create and explicitly use it’s own connection to the separate database without affecting the MODx connection. This would be accomplished by using mysql_connect with the optional parameter to create a new connection, and then passing that connection handle specifically to all subsequent mysql_ function calls.
                    • 19329
                    • 12 Posts
                    Quote from: xwisdom at Jun 27, 2005, 02:47 PM

                    Quote from: banzai at Jun 27, 2005, 01:07 PM

                    ..included file appears in the top of the page sad

                    Change the @EVAL to :

                    @EVAL
                    ob_start();
                    include "yourfile.php";
                    $rt = ob_get_content();
                    ob_end_clean();
                    return $rt;



                    I create a snippet with this code and as a result I’m getting.

                    Parse error: syntax error, unexpected T_STRING, expecting ’(’ in /<removed path>/manager/includes/document.parser.class.inc.php(769) : eval()’d code on line 2
                    Can it not be a snippet or have I missed something obvious?
                      • 26903
                      • 1,336 Posts
                      You can’t use EVAL in a snippet, remove that line, the rest should be OK, if you need to use the $modx object put ’global $modx’ as the first line
                        Use MODx, or the cat gets it!