Question about settings and plugin, etc?

4 posts by 2 authors in: Forums > CMS Builder
Last Post: Yesterday at 12:35pm   (RSS)

I have a modified Settings.dat.default.php file that presets many options for me such as a list of plugins, media.ini on, admin and dev email addresses etc. It was a pain to maintain when new versions came out  and the settings file was reorganized. I was hoping for a better way. Now with the default settings file now constructed programmatically, I see an opportunity to achieve my goal.

it would be great if we could provide a list of plugins and other settings in a custom config  file or something similar that could be integrated into the install. My goal is to remove the manual necessity to make these changes on each new project as very little is different from one client to the next.

For instance my email address for dev and admin don’t change, I always want certain plugins, I always have a custom help menu pointing at a help table, I always use media.ini (which has been customized with image sizes and info1-5 titles), my custom branding doesn’t change, and the list goes on. The only thing that changes for sure is DB info.

Jeff Shields

that is what I have been doing, A couple of times recent changes to the settings file broke that approach and I had to repair the files. Anyway, I will continue with what I was doing.

Jeff Shields

I added this function to my plugin with "pluginAction_addHandlerAndLink('Activate My Plugins', 'activateMyPlugins', 'admins');"

/**
 * Activate plugins in the /_activate-plugins.php file when the plugin is
 * activated.
 *
 * This function is executed when the plugin is activated. It reads the
 * "plugins.txt" file in this folder and activates each plugin listed in
 * the file.
 *
 * @return void
 */
function activateMyPlugins()
{

    // Get a list of all active plugins
    // @var array $activePlugins
    $activePlugins = array_filter(
        // Split the string into an array
        array_map('trim', explode(',', str_replace("\n", '', settings('activePlugins')))),
        // Remove empty strings from the array
        function ($value) {
            return $value !== '';
        }
    );

    $pluginsFile = fopen(__DIR__ . '/plugins.txt', 'r');
    $pluginName = '';
    while (!feof($pluginsFile)) {
        $pluginName = fgets($pluginsFile);
        $pluginName = trim($pluginName);
        //check if plugin is active or not
        if (! in_array($pluginName, $activePlugins)) {
            if ($pluginName != '') {
                activatePlugin($pluginName);
            }
        }
    }
}

I have a simple text file that lists the plugins I always want to install. I can then run the command from the action column from my plugin to activate my standard plugins.

Jeff Shields