A couple of months ago I posted an idea that might also be worth adding to this list:
http://forums.modx.com/thread/80126/all-purpose-snippet-is-this-a-good-idea-or-a-really-bad-one#dis-post-441501
The idea ist to have a snippet that can do all kind of stuff depending on its parameters.
You simple pass the function name and an double pipes seperated list of parametes to the snippet an you are ready to go:
/* Use str_replace on a string and put the result into a placeholder. */
/* Use str_replace on a string and put the result into a placeholder. */
[[!runFn?
&fn=`str_replace`
&args=`This||MODx||This CMS is awesome`
&ph=`test`
]]
[[+test]]
/* Result: MODx CMS is awesome*/
The whole snippet is listed in the post above. If there is a php function you want to use, it can most certainly be called with this snippet.
Another example:
[[!runFn?
/* Return the current date in a specific format */
[[!runFn?
&fn=`date`
&args=`'l jS \of F Y h:i:s A'`
]]
/* Result: 'Thursday 25th of October 2012 03:39:38 PM' */
This concept can be improved, especially in regards to security and error handling, but I think it is well worth the trouble to have a universal snippet.
Regards,
pepebe
[ed. note: pepebe last edited this post 10 years, 11 months ago.]