ObjectExplorer Snippet Tutorial
If you use this extra and like it, please consider donating. The suggested donation for this extra is $5.00, but any amount you want to give is fine (really). For a one-time donation of $50.00 you can use all of my non-commercial extras with a clear conscience.
ObjectExplorer displays information about the various objects in the MODX Revolution database. It's output is derived from the MODX schema file so it will display the current information for the version of MODX you are using.
Installing ObjectExplorer for MODx Revolution
Go to System | Package Management on the main menu in the MODx Manager and click on the "Download Extras" button. That will take you to the Revolution Repository (AKA Web Transport Facility). Put ObjectExplorer in the search box and press Enter. Click on the "Download" button, and when it changes to "Downloaded," click on the "Finish" button. That should bring you back to your Package Management grid. Right click on ObjectExplorer and select "Install Package." The ObjectExplorer snippet should now be installed.
To execute ObjectExplorer, just create a new resource to display the output and put a snippet tag for it in the Resource content field:
This tag is equivalent to the one above and can be used if you want to use a template variable to set the type of display, create the display dynamically based on user input, or call ObjectExplorer with runSnippet():
By default, ObjectExplorer will display a quick reference to the MODX objects in alphabetical order. This is the recommended display because it contains the fields of the objects (including inherited fields), the aliases of related objects, how to use those aliases and what they return. The full display is more detailed, but it doesn't show inherited fields and is much less useful.
Although the quick reference contains most of the information you might want and is generally more useful, it does leave some things out, such as the types of the aliases (aggregate or composite) and the default values of the fields. If you would like a full dump of the schema as an array, use this tag instead:
There are only two useful properties for ObjectExplorer at this point:
|full||(optional) display full version of schema||No|
|columns||(optional) Sets the number of columns in the jumplist at the top of the display||2|
If you change the number of columns, you'll probably need to change the width of div.objectexplorer_jumplist_div in the objectexplorer.css file.
The snippet code can be run outside of MODX if you would like to produce output on your local machine for reference or pasting. To do that successfully, you'll need to modify the path information near the top of the code. If you want the full display (as opposed to the quick display), you'll also need to set the $props['full'] variable to 1.
The ObjectExplorer class can also be used to display information on a single MODX object. To do that:
- copy the code at the top of the snippet that creates the classes
- call $explorer->parseSchema($model)
- set $objectName to the name of any MODX object (e.g. modResource, modChunk)
- call either $explorer->getQuickSingle('objectName')
- or $explorer->getFullSingle('objectName')
- return the result of that call
If you have the book and would like to download the code, you can find it here.
If you have the book and would like to see the updates and corrections page, you can find it here.
MODX: The Official Guide is 772 pages long and goes far beyond this web site in explaining beginning and advanced MODX techniques. It includes detailed information on:
- Installing MODX
- How MODX Works
- Working with MODX resources and Elements
- Using Git with MODX
- Using common MODX add-on components like SPForm, Login, getResources, and FormIt
- MODX security Permissions
- Customizing the MODX Manager
- Using Form Customization
- Creating Transport Packages
- MODX and xPDO object methods
- MODX System Events
- Using PHP with MODX
Go here for more information about the book.
Thank you for visiting BobsGuides.com
— Bob Ray