We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10525
    • 247 Posts
    I'm looking for the API docs for MODx. I found the API Documentation link in the manager and got to http://api.modx.com/revolution/2.2/.

    However, this isn't really an API in the sense I understand, which is an interface for programmers to interact with (I came from Java development).

    Can anyone direct me to the best place for finding a list and definitions of built-in MODx functions and constants/session vars etc which I can use in resources/chunks/snippets? (ie, not from extras).

    Thanks
      • 27708 MODX Staff
      • 2,502 Posts
      I could be wrong, but what I think you are looking for might be here: http://rtfm.modx.com/revolution/2.x/developing-in-modx/other-development-resources I don't get the API docs either. I am not a php developer though. I just want to know what classes and methods are available and how they get used.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        http://api.modx.com/revolution/2.2/ - but in my opinion this isn't really API documentation. It's just the automated docs created from the comments in the files. While you can find out what properties and methods are available for all the MODx and xPDO objects, there's no help in how they can be used.
          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
          • 3749
          • 24,544 Posts
          Quote from: smashingred at Nov 20, 2013, 07:24 AM
          I could be wrong, but what I think you are looking for might be here: http://rtfm.modx.com/revolution/2.x/developing-in-modx/other-development-resources I don't get the API docs either. I am not a php developer though. I just want to know what classes and methods are available and how they get used.

          I've said this before, but the API docs should not be listed under "Other Development Resources" since a) people won't find them there and b) API docs are arguably the *main* development resource.

          @Gav: There's documentation of most of the MODX and xPDO API in the Appendix of my book. It should be enough to get you going unless you're trying to do something exotic. The forums here are also an excellent source of API information -- just ask.

          MODX should really have something like php.net for online documentation. Out of all the API docs I've seen and used over the years, it's by far the best, imo.
            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
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Indeed. My PHP development would come to a screeching halt without php.net!
              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
              • 20413
              • 2,877 Posts
              Funny that they just re-designed php.net http://www.php.net/archive/2013.php#id2013-11-20-1
              (I like it)
                @hawproductions | http://mrhaw.com/

                Infograph: MODX Advanced Install in 7 steps:
                http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                • 3749
                • 24,544 Posts
                Quote from: mrhaw at Nov 21, 2013, 12:23 AM
                Funny that they just re-designed php.net http://www.php.net/archive/2013.php#id2013-11-20-1
                (I like it)

                So they have. wink

                I find it mildly disturbing after seeing the old style for so long.
                  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
                  • 10525
                  • 247 Posts
                  Thanks guys. Yes, it is something like php.net that I really want, so that I can code snippets and tap straight into my MODx methods and variables. Having a huge list of files and classes isn't really much use, as we just want to see the public methods and vars. I'm no expert in API docs, but I remember way back from learning Java at Uni that there was a standard way to comment every method and then churn out a set of docs for the public ones. That would be great here!

                  Bob, I've got your book so I'll check there. However, imagine being able to google "modx get username" and open a php.net-like page smiley Do you think the PHP mob would let us use their docs engine?....
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Every object has a get() method; that's inherited from the most basic "object" object. Here's what the docs say about modUser and its get() method - not very friendly, it needs examples.
                    Get a field value (or a set of values) by the field key(s) or name(s).
                    Inherited from: \xPDOObject::get()\xPDOSimpleObject::get()\modPrincipal::get()

                    Warning: do not use the $format parameter if retrieving multiple values of different types, as the format string will be applied to all types, most likely with unpredicatable results. Optionally, you can supply an associate array of format strings with the field key as the key for the format array.
                    Parameters
                    Name Type Description
                    $k string | array

                    A string (or an array of strings) representing the field key or name.
                    $format string | array

                    An optional variable (or an array of variables) to format the return value(s).
                    $formatTemplate mixed

                    An additional optional variable that can be used in formatting the return value(s).
                    Returns
                    Type Description
                    mixed The value(s) of the field(s) requested.
                      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
                      • 10525
                      • 247 Posts
                      Quote from: sottwell at Nov 21, 2013, 06:10 AM
                      Every object has a get() method; that's inherited from the most basic "object" object. Here's what the docs say about modUser and its get() method - not very friendly, it needs examples.
                      Get a field value (or a set of values) by the field key(s) or name(s).
                      Inherited...
                      Yes, not very friendly.

                      While on the subject of documentation, another feature of php.net is that user comments/suggestions/examples can be added below the docs content on each page. This would be VERY useful. It would make http://rtfm.modx.com/ a much more dynamic source of info. It would also speed up the turnaround time from initial reporting of errors/confusing text/suggested improvements to getting the changes made.

                      Is there a place I should suggest this?