Quote from: BobRay at Oct 10, 2014, 05:52 PMThis will get you the modContentType object and its name:
$contentType = $resource->getOne('ContentType');
$name = $contentType->get('name');
The other field names are listed here: http://bobsguides.com/modx-object-quick-reference.html#modContentType
If you want the content type for the current resource in the front end, use:
$contentType = $modx->resource->getOne('ContentType');
Just a followup on this. While your answer solved the question, I have a few notes for future readers.
I didn't need the "name" as in Bob's example, I needed the file extension, but found it funny that it is called "file_extensions" with a plural "s" on it. Nowhere else in MODX docs, API, or manager pages does it even hint that this is a plural field (I'm sure I missed it tho). The file_extentions" field is listed as a "string" and it returns a string (not an array) if you access it.
After a couple tests, I found that it is indeed a CSV field and you can have multiple extensions listed. I opened the "core/model/modx/modcontenttype.class.php" file and noticed a single public method "getExtension()" which returns the "first extension of this Content Type".
All that to say this, I didn't want to have to test and parse a CSV, so I was able to use this function like so:
$contenttype = $resource->getOne("ContentType");
$ext = $contenttype->getExtension();
This returns the first extension and worked perfectly.
Bob, I thank you for the object reference you created, but can you link to where I find this information in the official docs? Does MODX not have its own "object reference"? I was trying to find it here (
http://api.modx.com/revolution/2.2/) but it is a little difficult to use.