A scheme is a special file describing certain object structure. There are schemes for blocks, settings, promotions, etc. All schemes are stored in the schemas directory (...app/schemas).
An add-on can extend and override a scheme fully or partially (learn more).
A scheme contains data structure, that can be used by some other entity when processing the actions, defined by this scheme. For example, exim (export/import) is not attached to some particular item (product, page, etc.), and all its exported/imported data are described by a scheme.
There are three scheme types: data array, XML-structure, and set of functions. They cannot be mixed with each other (for example, it is impossible to describe data and functions in the same script).
A scheme returns an array. For example:
<?php
return array(
'layouts' => array(
'checked_by_default' => true,
'function' => 'fn_clone_layouts'
),
'settings' => array(
'checked_by_default' => true,
'tables' => array(
array(
'name' => 'settings_vendor_values',
'key' => '', // Do not needed
),
),
),
// Some other code
);
?>
A scheme is an ordinary text file, which content is read by fn_get_contents
. Now it is treated as out of date and is not used in the core.
<menu>
<items>
<subitems>
....
<subitems>
</items>
</menu>
Functions are decribed in such schemes. In most cases a scheme with functions is an addition to a scheme with data array. Than, it is not necessary to call this scheme separately. It is possible to include it with the help of include_once
at the very beginning of a file. If a scheme is a separate one (actions and variants in settings, for example), it is included as usual: fn_get_schema("settings", "actions.functions")
.
<?php
function fn_some_scheme_func1($params)
{
...
}
function fn_some_scheme_func2()
{
...
}
?>
There are to ways of extension - with the help of add-ons and with the help of editing tags.
To extend a scheme with the help of add-on, in the add-on catalog create the same directories and files structure as for the scheme. And add the .post suffix to a file name. For example, the path to the main file:
And the path to the extending file:
When including the extending scheme, the $schema
variable is passed into it. This variable contains extending data. The script works with this variable and returnes it at the end.
Example:
<?php
// $schema already contains data returned by the main scheme
$schema['news'] = array(
'modes' => array(
'manage' => array(
'permissions' => 'manage_news'
)
)
);
return $schema;
Here you can find more information on how to extend a scheme with an add-on.
Editing tags are used to form necessary scheme data depending on edition (Ultimate or Multi-Vendor). To extend a scheme with the editing tag, create the schema_[PRODUCT_EDITION] file in the scheme directory. For example, the path to the main file:
And the path to the editing tag file:
The $schema
variable is used here too. It contains extending data. The script works with this variable and returnes it at the end.
Use the fn_get_schema
function to get the scheme data:
function fn_get_schema($schema_dir, $name, $type = 'php', $force_addon_init = false)
Where:
$schema_dir
- scheme subdirectory relatively the schemas directory (permissions, settings).$name
- scheme file name without extension (admin, schema). If a scheme type is a function, the name will be as follows: actions.functions, variants.functions.$type
- scheme type (file extension) - php or xml.$force_addon_init
- indicates that disabled add-ons and their func.php files must be taken into account when including a scheme.During the scheme request the whole scheme tree is build including schemes of the add-ons.
Example:
$menu = fn_get_schema('menu', 'menu', 'php');
fn_get_schema('xxx', 'yyy')
.Questions & Feedback
Have any questions that weren't answered here? Need help with solving a problem in your online store? Want to report a bug in our software? Find out how to contact us.