Cotonti / Open Source PHP Content Management FrameworkContent Management Framework

Documentation / Developer Guide / Custom Installation Scripts

You can create custom installation profiles with your own Cotonti bundles using the installation scripts feature

When working with customers, we often need out-of-the-box solutions, accelerating the processes and minimizing the number of operations. For this purpose, Cotonti Siena 0.9.15 provides an opportunity of using installation scripts. Their primary function is building basic packages with preinstalled extension set, well-defined configuration, and targeted demo content.

To work with installation scripts you will need to review modules/install/inc/install.install.php file.

The file brief overview: there are 2 variables ($default_modules and $default_plugins) related to default modules and plugins set to install. $step variable is related to current installation step.

At zero step, the system prompts to select the installation language, but if a file {file_name}.install.php, is located in the root directory, the system will prompt to select it when installing Cotonti during the next steps.

The installation script file contains variables and hooks, executed after the end of each step (normal hooks are not available during the installation, as there is no database). Each step consists of three elements: form display (tags), data import, bug scanning (import) and installation itself (setup). 6 steps in total:

0. Select installation language and script.

1. Create cache directories and check the system compatibility.

2. Setup database connection.

3. Select the site’s language and theme, create an administrator account.

4. Install modules and plugins.

5. Complete the installation.

Accordingly, all our functions will be named in the following way:

cot_install_step([1-5])_(tags|import|setup)\(\)

Let’s consider an example of blog.install.php installation script:

// Modules and plugins checked by default
$default_modules = array('index', 'page', 'users', 'rss'); // the list of installed modules has been overriden
$default_plugins = array('ckeditor', 'cleaner', 'html', 'htmlpurifier', 'ipsearch', 'mcaptcha', 'news', 'search'
); // plugin list has been overriden

$L['install_body_message1'] = "Welcome to the Blog script<br/><br/>Please, relax and sit back.<br/><br/>".$L['install_body_message1'];
// The standard greeting message has been changed

function cot_install_step2_tags()
{
// the function replaces the default database prefix and sets another database name during the installation
	global $t, $db_name;
	$db_x = "cotblog_";
	
	$t->assign(array(
		'INSTALL_DB_X' => $db_x,
		'INSTALL_DB_X_INPUT' => cot_inputbox('text', 'db_x',  $db_x, 'size="32"'),	
		'INSTALL_DB_NAME_INPUT' => cot_inputbox('text', 'db_name',  is_null($db_name) ? 'cotblog' : $db_name, 'size="32"'),
	));
}

function cot_install_step3_tags()
{
// default theme has been replaced in the same way
	global $t, $rtheme, $rscheme;

	$rtheme = ‘symisun-03’;
	$t->assign(array(
			'INSTALL_THEME_SELECT' => cot_selectbox_theme($rtheme, $rscheme, 'theme'),
	));
}

function cot_install_step3_setup()
{
	// upon the 3rd step completion, we should set an admin panel theme…
	global $file;
	$config_contents = file_get_contents($file['config']);
	cot_install_config_replace($config_contents, 'admintheme', 'priori');
	file_put_contents($file['config'], $config_contents);
}

If you want to skip some step, you just do all the necessary things in our function and then call $step++.


1. Macik  2013-11-10 05:08

Thanks: 0

Thanks Pavel.

2. esclkm  2013-11-10 16:49

Thanks: 0

nzch

3. PRoHtml  2013-11-12 11:38

Thanks: 0

Полезная информация, спасибо

4. Yusupov  2013-11-25 10:23

Thanks: 0

Не помешала бы возможность добавлять свои конфигурационные параметры для более тонкой настройки сайта при установке.

5. esclkm  2014-01-03 08:41

Thanks: 0

это есть) жеж.. остально mysql )))

Total: 5, on page: 5

Only registered users can post new comments