If you plan to modify the app to fit your needs, then you can do it by developing your own plugin. Thus, your modification will be compatible with app updates.
In this article, using the example of the “Hello, world!” plugin, I will explain how to create your own plugin in the app.
Initially, the project used the Symfony PHP Framework version 1.3. But over time, support for this version of the framework has ceased, and I decided not to use any framework in order not to depend on it, however, when writing a program, I created a similar architecture.
Start of work
Download the “Hello world!” Plugin and unpack the archive into the /plugins folder
Open file /config/server.php and in option AVAILABLE_PLUGINS add “hello” in result you should have next code:
This variable lists all available plugins that will be automatically connected.
Link to the page
As a result, as a system administrator, you should see a link to the “Hello world!” Page in the left menu. Click on it and you will be taken to the page with the “Send Message” button.
The link looks like this:
hello — Plugin name.
my_page — Page name.
index — Action name.
When you open “index.php?module=hello/my_page/index” then run next actions:
plugins\hello\application_top.php(not required file)
In this file you can include all libs
plugins\hello\modules\my_page\module_top.php(not required file)
This file is included in any actions on this page. Can be used for access checks, etc.
plugins\hello\modules\my_page\actions\index.php(not required file)
The link in the app is formed using a special function url_for()
The functions for working with links are located in the file. includes\functions\urls.php
HTML form and popup
After clicking on the “Send message” button, a pop-up window will open with a simple field for entering text. An example of this form is located in the file
Functions for working with html forms are located in the file includes\functions\html.php
An example of a database query can be found in the file plugins\hello\classes\my_class.php
$user_info_query = db_query("select * from app_entity_1 where id='" . $app_user['id'] . "'");
if($user_info = db_fetch_array($user_info_query))
In this request, we select information about the current user.
Functions for working with the database are in the file includes\functions\database.php
$app_user - this is a session variable that stores information about the current user.. group_id — this is the current access group. For administrators group_id=0.
File plugins\hello\menu.php included automatically. In this file, you can specify a link to a page in the menu.
$app_plugin_menu['menu'] = array('title'=>TEXT_PLUGIN_HELLO_WORLD,'url'=>url_for('hello/my_page/index'),'class'=>'fa-anchor');
menu — main manu
reports — menu “Reports”
account_menu — user menu in the upper right corner.
In the main menu, you can create nested menus, for example:
$s = array();
$s = array('title'=>TEXT_PLUGIN_HELLO_WORLD,'url'=>url_for('hello/my_page/index'),'class'=>'fa-anchor');
$app_plugin_menu['menu'] = array('title'=>TEXT_PLUGIN_HELLO_WORLD,'url'=>url_for('hello/my_page/index'),'class'=>'fa-anchor','submenu'=>$s);