We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21913
    • 10 Posts
    I’m starting to get my head round using modx as a cms but am having problems with using it as an application framework. I’ve got a fair amount of experience of creating web apps with php and realise that I’ll have to come at things a bit differently with modx. I’ve got quite a few questions, such as

    • Where do I put my code?
    • How do I pass parameters between pages?
    • How do I return a page from a form processing procedure?

    etc. etc.

    Is there an idiot’s guide to using modx as an application framework anywhere or can some kind soul point me in the right direction?

    Thanks
      • 11206
      • 73 Posts
      if you’re experienced with php then you can write your php as snippets, or call php files.

      one way is to use documents to hold your php.

      as for passing variables, if they’re forms, use $_GET or $_POST to get the vars from the form, or sometimes I even add values onto the url (&var=something). When you’ve processed the forum, you can either call a page that you have created in modx.

      Basically, Snippets are what you want to be looking at. Have a look at some that have been developed, it will give you a good idea of how the fit into the framework.

      in snippets vars can be passed to them from when you call the snippet.

      so basically, if you know php, you don’t really need to come at things in a different way at all.

      i find the DBAPI great with modx, as it enables me to use the DB, the structure that modx has set up (the framework) and then write code how I want to. Generally that includes a fair combination of javascript, php and to some extent (depending on the site) flash AS.
        • 7231
        • 4,205 Posts
        I’ve got a fair amount of experience of creating web apps with php and realise that I’ll have to come at things a bit differently with modx.
        This is not entirely true. You can code in the normal fashion that you are accustomed to and use the MODx api to access document information. Some snippets will use the api extensively while others will bypass it alltogether and use standard code, it is really up to you how you do it.

        Check out the wiki article Creating Snippetsfor some good tips.
          [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't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 21913
          • 10 Posts
          Well, talk about trying to make things more complicated than need be! I got my form working with no problem at all. Many thanks to both of you for your fast and helpful advice. No doubt I’ll be back with a few more questions in the future.
          All the best.
            • 21257 MODX Staff
            • 730 Posts
            If you want start using some of the object-oriented goodness that forms the core of the not-too-distant future MODx, check out xPDO. http://www.xpdo.org/ Get your head around (if it’s not already.. I don’t mean to assume ;-) modelling and the object-relational bridge concept. You can model your web applications with xPDO and use it in your 0.9.6.x sites today. I’ve done a number of projects like this already. xPDO also plays very nicely with ajax interfaces like extjs, YUI etc etc. Without explicitly setting out to learn it, I’ve slowly come around to a near MVC approach using xPDO with 0.9.6.x. Basically, xPDO is the M (model), templates and chunks are the V (views) and snippets are the C (controllers). (A tad oversimplified of course smiley I can’t wait to start building real apps in 0.9.7. So close I can smell it! (or is that my dog?)
              Mike Schell
              Lead Developer, MODX Cloud
              Email: [email protected]
              GitHub: https://github.com/netProphET/
              Twitter: @mkschell
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Yeah, sure, blame the dog grin
                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
                • 21913
                • 10 Posts
                @netProphET
                Thanks, I’ll have a look at xPDO. And it’s usually best to assume that I’m a bit ignorant in certain areas. Sometimes my nickname is more appropriate than I’d like it to be wink