Hi,
Coming from a Joomla environment I was used to having all php code for customisation outside the database, just sitting as plain files in the file system.
Modx has a different approach, at least for snippets. As far as I know, snippets are stored in the database and evaluated when called upon.
After about a month working with modx, I find that developing more complex snippets is very cumbersome process. The modx editor is not really equipped for this.
What I do now, is develop complex snippets as classes outside modx and use the snippet as a mere wrapper. This allows me to develop the class using a decent development environment.
Would that be an advisable approach?
MODx Revolution / MAMP / OS X
Yes, many people do that. If you’re using MODx Revolution, you could also check out the CodeMirror plugin which provides rudimentary code editing for snippets.
-
☆ A M B ☆
- 24,524 Posts
Indeed, any snippet more than a few lines should be developed this way. Basic initialization (checking for parameter settings, for example) and then include the main file for the snippet. The Jot snippet is a good example for Evo.
To clarify my original post, you can not only put the class in a file, but the snippet as well so the snippet in the DB can be a single line:
return include 'path/to/snippet/code';
Quote from: BobRay at Sep 01, 2010, 12:01 AM
To clarify my original post, you can not only put the class in a file, but the snippet as well so the snippet in the DB can be a single line:
return include 'path/to/snippet/code';
Excellent! Thanks
MODx Revolution / MAMP / OS X