Before MODx I was doing everything from scratch in PHP. It’s common practice to have a file which contains system settings, which is included into every page of the site. It would contain system-level stuff like database connection info, SMTP server connection info, paths to libraries but also application-level stuff like destination email addresses or how many photos to show on a gallery page and so on.
MODx system-level settings are already in a file of course. I wouldn’t want to hack that file to add my application-level stuff, so I was looking for a place to put these settings that would make them easy to edit and easy to utilize.
Evolution.
The solution I have ended up using in Evolution is simple. It’s a plugin where I just create placeholders which act as the settings I need in my application.
An example:
$e = &$modx->Event;
switch ($e->name) {
// don't forget to check off OnWebPageInit in the System Events tab
case 'OnWebPageInit':
// how many articles to summarize on News Index pages?
$modx->setPlaceholder('numNewsIndexSummaries', 5);
// how many articles to summarize per page on News Archive pages?
$modx->setPlaceholder('numNewsArchiveSummaries', 10);
// rss
$modx->setPlaceholder('numRSS', 20);
// email
$modx->setPlaceholder('someoneToSendSpamTo', '[email protected]');
break;
}
Then, say I have a Ditto call in the site that summarizes news articles on an archives page, I can just do this:
[[Ditto? &extenders=`request,dateFilter` &start=`[+numNewsIndexSummaries+]` &summarize=`[+numNewsArchiveSummaries+]` ...
It may not appear all that useful at first, until you have 11 unique Ditto calls sharing certain parameters, but differing in other ways. Then it’s a lifesaver when it comes to testing and implementation activities.
Revolution.
In Revolution, it’s already baked in! Context Settings. Right-click on your context (e.g. web) and select Edit Context. In the Context Settings grid, click Create New and you’re on your way. The "Key" is what determines the modx tag name, and Value is obvious.
To "migrate" my above Evo plugin/placeholder settings, I would just create Context Settings with keys like numNewsIndexSummaries, numNewsArchiveSummaries and so on, and give them the values that I want. Happily, Revo’s new tag syntax makes using these settings a no-brainer:
[[Ditto? &extenders=`request,dateFilter` &start=`[++numNewsIndexSummaries]` &summarize=`[++numNewsArchiveSummaries]` ...
Examples used in this post are fictional. Any similarities to actual persons, places or things is purely coincidental.