Question about settings and plugin, etc?

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

Hi Jeff, 

We have a number of users who create their own customized CMSB distributions in various ways.

For installs, perhaps the easiest way would be to have a folder with your customized files, e.g.: 

  • /cmsb/data/settings.dat.php
  • /cmsb/data/media.ini.php

Then when you download a new version zip drag those files in.  So if you have these folders: 

  • /my_source_files/cmsbuilder_3_73_build2773_release/
  • /my_source_files/cmsb_my_customized_files
  • /my_source_files/cmsb_my_release_version

Then everytime you download a new version you just drag/copy the release files in the "my_release_version" folder, and then drag the my_customized_files folder in, and you're good to go.

Because there's no /data/isInstalled.php semaphore file yet, it will run the install routine, and because the media and settings files are already there it should use them.

That might be the simplest, but you could also have a plugin check for files and customize them as needed.

Let me know if that will work for you.

Dave Edis - Senior Developer
interactivetools.com

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