Deutsche Version subscribe RSS feed


MODx-Feature: MODx API Cheat Sheet

Tags: MODx, Snippets | last edited: 23.03.2011

Admittedly, there are better documentations than the current MODx one. Fortunately, you don’t have to refer to it too much once you have figured out how MODx works generally. The exception to the rule is the MODx-API, and for that reason I have - step by step - created a MODx-API cheat sheet in which the most important functions are listed:

MODx Evolution API cheat sheet

			$modx->setPlaceholder('placeholder_name', $var);

			// Print placeholders in HTML
			runSnippet('snippet_name', $params);

			// Run snippet in HTML

			// Print chunk in HTML
			parseChunk('chunk_name', $params, '');

			// Get MODx documents
			$document=$modx->getActiveChildren($id, 'menuindex', 'ASC');

			// MODx document array

			// Get the value of template variables
			$document_tvs=$modx->getTemplateVarOutput(true, $id);

			// Print template variables in HTML

			// Make URL in HTML
			sendRedirect('', $count_attempts, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently');

			// Forward to a new MODx document without reloading the page

			// get MODx configuration

			// Get MODx configuration in HTML
				case "OnBeforeDocFormSave":

			// TV @SELECT
			@SELECT pagetitle FROM modx_site_content WHERE parent = 329 ORDER BY pagetitle 

According to my experience, these API functions are the most commonly used code snippets when developing your own snippets or modules.

Background: MODx-API

With the help of MODx-API, MODx can be extended quickly and comfortably by your own functions. More on this can be found in the article “MODx-Feature: Snippets – all rounders”.

I am looking forward to suggestions on how to extend the MODx-API cheat sheet!


Write a comment

Comments are not active anymore


Sydney Church visit website

08.12.2011 19:51:24

Thank you for sharing the compilation.
This is what I need =)

Bogdan visit website

04.08.2010 09:45:07

Hi Dan,

I am glad you find my cheatsheet useful!

Regarding your question: I am afraid I can’t help you at all with this. I switched to jQuery some time ago and I never was very deep into MooTools or the MODx Manager.

I would suggest to ask the official MODx developer team what it would take to change the Manager interface. My guess is that its a LOT of work, but it would be nice to have different interfaces to choose from though.

Good luck!


03.08.2010 17:32:37

Nice modx cheatsheet Bogden! very handy.

Q: Bogden, you seem to have a knowledge of mootools + modx — would you know how swap out the revolution 2.0 manager for the mootools mocha ui interface? I’d love to be able to have mocha as the modx backend, instead of the standard revo manager module.

Any ideas?

Jarkko visit website

18.02.2010 12:05:35

Thanks. Really very useful info!

Milos visit website

30.09.2009 12:31:06

Dear Bogdan,

How do you embed php code into modx pages and syntax highligt like that?

If you visit my site, you’ll see how I did it, but I like your way better.

Any instructions? Thanks

Bogdan visit website

21.08.2009 13:37:00

Hello Patrick,

I am glad the API Cheat sheet is useful to you. Spread the word if you like MODx!


21.08.2009 13:18:37

Thank you for this. I’m a n00b to Modx but I am a php professional. Just getting the API objects so handy like this is great. Thanks again.

Bogdan visit website

23.04.2009 19:39:32

Thanks for the suggestion. This cheat sheet is for developers using the MODx API indeed. However there are quite a few tutorials for MODx beginners, though a tutorial is not the same as a cheat sheet of course.


learn to play craps visit website

23.04.2009 14:14:41

I think ideally there should be 2 cheat sheets (as if you haven’t got enough to do already Grin): one for developers with API stuff etc, and one for the actual users of the website (our clients) with all the basics; how to make a new page, add images, stuff like that.

Bogdan visit website

01.02.2009 17:31:28

Just added the examples the associative arrays MODx document arrays.

Bogdan visit website

27.01.2009 09:08:27

Thanks for your feedback Shane! You are right, I forgot the document arrays as I take it as granted to know how to use them. I will update the cheat sheet in the next few days.

Shane Sponagle visit website

26.01.2009 01:02:22

Bogdan: This is a great simple cheat sheet. Bookmarked for reference. Cool site as well. I look forward to more stuff on MODx.

I think that a nice thing to include in the cheat sheet would be examples of how to work with the associative arrays that the api returns. I see many people stumped with how to work with the results.

Bogdan visit website

14.12.2008 16:48:32

Thanks Zaigham. Never thought about offering a printable Version since its not like a Photoshop shortcuts cheat sheet you can use just by looking at it. The MODx-API cheat sheet you certainly want to copy/paste the lines you need, isn’t it?

Zaigham visit website

12.12.2008 21:20:31

Very nice work Bogdan.

Maybe a downloadable pdf or png version of the same would be helpful for those who like to print the sheets and use them physically.