Add this code to the very beginning of the snippet code in the Manager, immediately after the introductory comments section:
/* Add config file capability - sottwell Aug 2009 */
$config = isset($config) ? $config : 'default';
if(file_exists(MODX_BASE_PATH . 'assets/snippets/webloginpe/configs/' . $config . '.config.php')) {
include MODX_BASE_PATH . 'assets/snippets/webloginpe/configs/' . $config . '.config.php';
}
/* end of config addition */
Create a default.config.php file like this:
<?php
// default config file for WebLoginPE
// use this format: $parameter = 'value';
and put it in the assets/snippets/webloginpe/configs/ directory.
Create as many whatever.config.php files as you need, such as reg.config.php:
<?php
// config file for registration form
$type='register';
$registerTpl='wlpeRegister';
$regRequired='email,username,password';
$customTable='client_attributes';
$groups='clients';
$notify='[email protected],[email protected]';
$notifyTpl='wlpeNotifyTpl';
$registerSuccessTpl='wlpeRegSuccess';
$customFields='firstname,lastname,companyname,title';
And use this snippet call:
[!WebLoginPE?config=`reg`!]
Now your snippet calls are much cleaner, you can use ? = & in the parameter values if you need to, the list of parameters is much easier to see at a glance, much less likely to get trashed by accident, and TinyMCE can’t mess up your parameter delimiters. Even move the templates out of chunks directly into the config file!
Oh, and you can use MODx API functions (or any other PHP code) to make conditional parameters and/or values, too.