We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14349
    • 44 Posts
    I used to be into Python/Ruby via command line MVC programming.

    I know in the future modx elements will be able to be static so I can edit snippets through vim and such (can you tell I like the command line! : ) )

    Anyway - is there a way right now where in php scripts I can include the modx class/classes -basically I need to build and run a snippet outside of the manager

    I’m thinking I just make a php file and include the nessicary classes so I can do things like modx->getCollectionI() and such.....

    Is there a list of classes - or class (maybe jus the modx class) I should include ?


    Modx is amazing for end users - and great for quick programming - but some sites need heavy programming and i’m used to doing it via command line.
      • 1778
      • 659 Posts
      Hi

      Have a look at this post http://modxcms.com/forums/index.php/topic,48952.msg286100.html, especially the answer by Splittingred, he explains how he developps his 3PC outside Modx... Maybe a way to explore for you...

      Hope this helps
      Cheers
        • 3749
        • 24,544 Posts
        Generally, all you need is this (after defining MODX_CORE_PATH):

        require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
        
        $modx= new modX();
        $modx->initialize('mgr');


        Note, though, that you can also keep all snippet code in files and just create a "shell" snippet in the Manager with:

        <?php
        return include "path_to_snippet_file";
        ?>
        

        That way, you can edit the snippet code in your favorite editor and still test it inside MODx, which is often more practical.
          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