Developing and connecting plug-ins

<< Click to Display Table of Contents >>

Navigation:  For developers >

Developing and connecting plug-ins

DataLife Engine provides convenient mechanisms for connection of developed script modifications. These mechanisms provide operation of plug-ins after updating to a new version of the script, because these mechanisms allow you to connect plug-ins without editing script files. You need to add the following tag to connect your plug-ins:


{include file="engine/modules/mymod.php"}


Where engine/modules/ is the path to the file of your plug-in, and mymod.php is the name of the connected file. Standard plug-in files of DataLife Engine are located in this folder and we recommend you to use this folder, but it is not required and you can store the file in any other folder on the server. The only safety restriction when you add the plug-in is that there should not be write permissions (CHMOD 777) for the folder of this file. We also recommend that you use relative paths when connecting plug-ins. DataLife Engine automatically detects relative paths and connects your plug-ins based on the settings of the script and paths where the script is installed. Thus, you can create a generic installation instructions for your modifications.


You can also connect your PHP files of your plug-in giving various parameters to them, such as:


{include file="engine/modules/mymod.php?param=value1&variable2=value2"}


Thanks to such connection features, you can make your modifications multifunctional. They can perform a variety of roles and functions in various connections. Passed variables are available in your plug-in as $param and $variable2 respectively.


Starting with DataLife Engine 8.3, you can specify a template script tags as parameters to the plug-ins. For example, you can transfer the article ID as the parameter to your plug-in when you add the following to the full article template: {include file="engine/modules/mymod.php?param={news-id}"}. Note: Transferred parameters are analogous to GET parameters. Hence, when choosing transferred tags, you must consider the limitations of GET string. In other words you can not pass the contents of the full article as a parameter.


Also you can use your plug-ins to replace the main block where all the news and the other basic information is displayed. For that you must use this tag in conjunction with [aviable=section]text[/aviable] and [not-aviable=section]text[/not-aviable] Tags description is in "Displaying news on pages" section. You can use a standard sections list or you can create your own section of the website, passing it to the URL of the browser. For example, you want to add your own section to standard sections of the website to display the information form your plug-in. Let's say you want to create the FAQ. For this, write the following in main.tpl:


[aviable=faq]{include file="engine/modules/mymod.php"}[/aviable]



After this connection your section from your plug-in will be displayed instead of news when accessing the address:


Only one thing is required for the work of your plug-ins and for display of the information in a place where you located this tag. Information must be displayed using the echo PHP function. Consider the example of a simple plug-in and the information output. Let's create mymod.php with the following contents:




echo "Test plug-in";




The following text will appear in the place where you add it into a template: Test plug-in


The list of DLE variables and classes that you can use in your plug-in, without a declaration:


$is_logged - Contains information whether the visitor is an authorized user or a guest. May be true or false.


$member_id - Contains an array of information about the authorized user, including all his information from the profile.


$db - DLE class for work with the database.


$tpl - DLE class for work with templates.


$cat_info - Array that contains the information about all the categories on the website.


$config - Array that contains the information about all the script settings.


$user_group - Array that contains the information about all the user groups and their settings.


$category_id - Contains the ID of the category that is viewed by the visitor.


$_TIME - Contains the current time in UNIX format with the bias settings in your script settings.


$lang - Array that contains the text of the language pack.


$smartphone_detected - Contains information about whether the user is viewing the website from a smartphone or from a standard browser. May be true or false.


$dle_module - Contains information about the section of the site that the user is viewing, or the information of do variable from the URL bar of a browser.


Warning: Your module should only read data from the these variables. Changes to the values of the variables will cause malfunction of the standard features of the script and its further incorrect work.