We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3177
    • 137 Posts
    bertcatsburg Reply #1, 16 years ago
    Hello,

    We have a website in maintenance which is build in a self-build CMS based
    on ZendFramework and something ridiculously complicated with Ajax...
    My customer wants some extra functionality in that CMS system.

    My idea is to install MODX next to that system, let the users do the
    maintenance of that part of the website in MODX (not the pages, but probably
    they will be Chunks), and modify the ZendFramework code to read straight
    from the MODX tables.

    My question is if it is possible to read chunks or documents from
    another system than MODX. Some sort of API on MODX as a whole.

    Thanks in advance for your time and aswers,

    Bert Catsburg
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      If you just want to get the content of the chunk or resource, you can easily access the site_htmlsnippets table or the site_content table. If you want dynamic content (content after a snippet has been run, for example) you could have the snippet on a resource with no template, and use the actual resource’s URL to have MODx process it.

      The Vanilla forum’s single sign-on plugin does this; it uses a MODx (or any other external application) page with a snippet to generate the user data from the MODx login and scrapes that data to have the user logged in to the Vanilla system.
        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
        • 3177
        • 137 Posts
        bertcatsburg Reply #3, 16 years ago
        Hm, you’re right in your second example. I could just run the url in an iframe. But I think it might be too mucht overhead. I need different ’blocks’ in that site, so every block would start up the whole MODX-system.
        The first example also crossed my mind. But I was hoping for some elegant solution in which you call MODX as an API. Link ’execute the config, load the MODX-class and go through the API to the MODX elements’.
          • 26903
          • 1,336 Posts
          Yes, you can do this, in your external script basically include the index.php file from MODx, you can cut this down a bit and set the in API MODE constant, this will create a modx object for you on which you can call the MODx API from your external scripts. remove the request handler at the bottom and your good to go.
            Use MODx, or the cat gets it!
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            You can use cURL to open the URL and get the content from the page as a string. No iframe necessary.

            http://www.php.net/manual/en/curl.examples-basic.php

            Or if your PHP configuration allows opening URLs as files, you can use file_get_contents.

            http://il2.php.net/manual/en/function.file-get-contents.php
              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
              • 3177
              • 137 Posts
              bertcatsburg Reply #6, 16 years ago
              Ok, that is clear. I have to test these solutions. Probably I will come back asking how far I can strip the index.php. But for the moment I take the full index.php.
              Thanks, for all your help.
                • 3749
                • 24,544 Posts
                I believe this is all you need:

                <?php
                define('MODX_CORE_PATH', 'full/path/to/your/modx/core/');
                define('MODX_CONFIG_KEY', 'config');
                require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
                $modx= new modX();
                $modx->initialize('mgr');
                


                I think the xPDO class will come along for the ride.
                You’ll need a correct core/config/config.inc.php file (if MODx is installed, it should already be there).
                  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
                  • 3177
                  • 137 Posts
                  bertcatsburg Reply #8, 16 years ago
                  Hello BobRay,
                  Interesting solution.
                  Is this Evolution or Revolution?
                    • 36416
                    • 589 Posts
                    Quote from: bertcatsburg at Sep 23, 2010, 02:45 AM

                    Interesting solution.
                    Is this Evolution or Revolution?

                    Revolution, for Evo you have this:
                    http://wiki.modxcms.com/index.php/Use_AJAX_with_modxAPI

                      • 8930
                      • 44 Posts
                      Thanks Bobray for this usefull contribution. It was exactly what I was looking for to validate a form with an ajax request (server site validation and email)

                      Works perfectly!

                      Thanks for you site too, which is a gold mine...
                        Equilibre Webdesign - Conception et r