We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9732
    • 10 Posts
    I have a chunk "pags" with this code: "<div id="pags"><a href="http://www.anotherserver.com/userfolder/formulario.php"></a></div>"
    and a document with this code:"[!pags!]", but nothing show when I load page.

    The document load in a frame at center of my main page, the "pags chunk" need load external php script with a user form and show the user form in the same frame of document.

    Anybody have a example about load external php script from chunk or snippet in a document template?

    Thank in advance.
      • 26931
      • 2,314 Posts
      Hi,

      if it’s a chunk you have to call it like that: {{pags}}

      j
        • 9732
        • 10 Posts
        I try, but same result, nothing show, only page title!
          • 30223
          • 1,010 Posts
          I’m not sure from your description what you want to achieve but
          <div id="pags"><a href="http://www.anotherserver.com/userfolder/formulario.php"></a></div>

          is certainly not going to load anything into a frame. This is simply a link without a description. Take a look at the source of the page where you placed {{pags}} and see if you can spot the above markup. I bet it’s there (that is if ’pags’ is a chunk indeed). It’s simply not showing anything because there’s nothing visible to show.

          Try:
          <div id="pags"><a href="http://www.anotherserver.com/userfolder/formulario.php">Go there</a></div>
          [

          If you want to load an external script into a page you need to use a snippet and write some php to include the external script. However it depends on what the external script was designed for if you get any sensible output or not.

          if you create a new snippet with code something like this you should be able to include an external script.

          <?php
          if( isset($script) && file_exists($script) ) {
          
             return include($script);
          
          } else return "Script could not be found";
          ?>


          You would insert this into your page with something like this:
          [!snippetName? &script=`/path/to/external/script.php`!]

          This is a very simple example and there are better ways of including php into your page but without knowing what your external script looks like this is the easiest I can offer.
            • 9732
            • 10 Posts
            I try your code, but show "Script could not be found".

            The script load from browser not problem! You can see at http://www.publitarget.cl/chequesalud/formulario.php
              • 7231
              • 4,205 Posts
              The form has no destination: action="" so when it POST the data it does not necessarily connect to itself (as you would expect in regular php pages, in modx all pages are index.php so it needs more info). Try setting the action to action="[~[*id*]~]" so that it sends to itself.
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don&#39;t know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 9732
                • 10 Posts
                My problem is show content of external php script, for the moment, the reference script is not implemented for user action for now.

                I need load external php script in page placeholder with snippet.

                Thanks in advance
                  • 7231
                  • 4,205 Posts
                  If the script is on your server the above script should work. If it says file not found then the path to the file is wrong or the file does not exist.

                  If you are trying to load a remote script (from another server) then you will need to find out how your host is configured to handle this. In many cases the server is configured to not allow this since it would make it too easy to add malicious scripts. For remote files file_exists will not work since it only checks locally. Try removing the file_exists check and see it if works.
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 9732
                    • 10 Posts
                    Now show:
                    "« MODx Parse Error »
                    MODx encountered the following error while attempting to parse the requested resource:
                    « PHP Parse Error »

                    PHP error debug
                    Error: include(’http://www.publitarget.cl/chequesalud/formulario.php’) [function.include]: failed to open stream: No such file or directory
                    Error type/ Nr.: Warning - 2
                    File: /home/.mamba/chequesalud/chequesalud.cl/manager/includes/document.parser.class.inc.php(766) : eval()’d code
                    Line: 4

                    Parser timing
                    MySQL: 0.0118 s (4 Requests)
                    PHP: 0.0557 s
                    Total: 0.0675 s
                    "
                    I think in server security problem, too
                      • 9732
                      • 10 Posts
                      Sorry, I remove single cuote (’) from reference and show:
                      « MODx Parse Error »
                      MODx encountered the following error while attempting to parse the requested resource:
                      « PHP Parse Error »

                      PHP error debug
                      Error: include() [function.include]: URL file-access is disabled in the server configuration
                      Error type/ Nr.: Warning - 2
                      File: /home/.mamba/chequesalud/chequesalud.cl/manager/includes/document.parser.class.inc.php(766) : eval()’d code
                      Line: 4

                      Parser timing
                      MySQL: 0.0053 s (0 Requests)
                      PHP: 0.0541 s
                      Total: 0.0594 s

                      This is a server security problem, is posible bypass this?