Седат Игдеджи, Sedat Igdeci, Cedat Igdeci, Bekir Igdeci, Lidiya Igdeci, Elizaveta Igdeci

Plug-in example: templates engine management

Our task is to add the checkbox “1С-Bitrix” on the domain edit form. Depending on the checkbox status, the configuration file Apache will contain different values for the directive open_basedir:

  • the checkbox is selected — open_basedir is “none”;
  • the checkbox is not selected — the open_basedir value equals the domain home directory.

Usually a plug-in consists of the XML file that describes the plug-in and where you can add/hide interface elements, and a handler. The handler is a script that will be called before or after a certain action of the control panel. Add the XML to the directory /usr/local/mgr5/etc/xml/ and name it as ispmgr_mod_<name>.xml, eg. /usr/local/mgr5/etc/xml/ispmgr_mod_bitrix.xml

XML description of the plug-in

<?xml version="1.0" encoding="UTF-8"?>

<handler name="bitrix" type="xml"> 
         <event name="webdomain.edit" after="yes" /> 

<metadata name="webdomain.edit" type="form">
	<page name="domain">
		<field name="bitrix">
          	<input type="checkbox" name="bitrix"/>

<lang name="ru">
	<messages name="webdomain.edit">
	<msg name="bitrix">1С-Bitrix</msg>
	<msg name="hint_bitrix">Select the checkbox to generate optimal configuration files for 1С-Bitrix</msg>

<lang name="en">
        <messages name="webdomain.edit">
        <msg name="bitrix">1C-Bitrix</msg>

The metadata section describes that a new field (name=”bitrix”) of the checkbox type (type=”checkbox”) will be added to the WWW-domain tab (page name=”domain”) on the edit form (type=”form”) of the web domain (name=”webdomain.edit”)

The handler section describes that after (after=”yes”) the web domain is edited (webdomain.edit) the script named bitrix (handler name=”bitrix”) of the xml type (type=”xml”) will be called. 

The type xml means that the script receives the XML file with parameters to stdin from the control panel. The plug-in must return the same XML to stdout where custom parameters can be added or existing parameters can be modified.

The lang section defines description and a hint in the Russian and English languages. 

After you have added the custom xml, restart the control panel

/usr/local/mgr5/sbin/mgrctl -m ispmgr exit


Add the handler script to the directory /usr/local/mgr5/addon . The file must have the same name as it is specified in the handler section of the xml. In our example, this is the file /usr/local/mgr5/addon/bitrix:


if [[ "$PARAM_bitrix" = "on" ]] 
                cat | sed 's|</doc>$|<params><CUSTOM_BASEDIR>none</CUSTOM_BASEDIR></params></doc>|'
                cat | sed 's|</doc>$|<params><CUSTOM_BASEDIR>'$PARAM_docroot':.</CUSTOM_BASEDIR></params></doc>|'

The value of the variable $PARAM_bitrix is checked in the condition. The control panel sends some parameters to the environment variables and they can be used in the plug-in handler. $PARAM_bitrix is the variable that can be on, if the checkbox “1С-Bitrix” is selected on the domain edit form and can be off, if the checkbox is not selected.

The plug-in sends to the control panel the same xml file that it has received to stdin, but it adds its custom parameter CUSTOM_BASEDIR to the xml. This parameter can have the value none, if the checkbox “1С-Bitrix” is selected or <domain home directory>, if the checkbox is not selected.

Finally, edit the template engine file that will define what directives will be specified in the configuration file Apache.

In the file /usr/local/mgr5/etc/templates/apache2-vhosts.template change

 php_admin_value open_basedir "{% $BASEDIR_PATH %}"


 php_admin_value open_basedir "{% $CUSTOM_BASEDIR %}"

Now the value open_basedir will be defined by the variable CUSTOM_BASEDIR that we add with the plug-in and define its value ourselves depending on the checkbox “1С-Bitrix” on the domain edit form. 

Седат Игдеджи, Sedat Igdeci, Cedat Igdeci, Bekir Igdeci, Lidiya Igdeci, Elizaveta Igdeci