Infoblocks

Information blocks in SyDES - is any php or html code that can be displayed on the front with a special token, like {iblock:iblock_name}, written in the text of the page, layout or template.

They stored in system/iblock/iblock_name/iblock.php.

 

Templates

In the simplest embodiment, this need only a single file. But the system allows to increase the functional of iblocks on a much larger scale. For example, if your information block collects some data, and then displays them beautifully decorated, you may need several different templates for different pages. In this case, create in the iblock folder file default.php, which will contain the default template. It will automatically fetch after the iblock execution. Then you can add more files with unique names and other templates place there. To apply these templates, use the template argument in the iblock token {iblоck:iblock_name?template=simple}.

 

Settings

In order to get through the iblock token could pass arguments as URL-encoded string is sufficient to register at the beginning of the code line of the form

$defaults = array(
	'show' => 'some',
	'limit' => 20,
    'param' => true
);
$args = array_merge($defaults, $args);

This will be the default settings and change them if necessary.

For example: {iblоck:iblock_name?show=mydata&limit=5&param=1&title=My+title}

 

Iblock as modifier

One of the core features of the iblocks is the ability to overwrite the output data like plug-ins.

For example by creating information block modifier_products and place it at the beginning of the layout for the products, you can edit or format the catalog metadata before output.

$this->response->data['image'] = isset($page['image']) ?
	'<img src="/cache/img/250_250_c' . $page['image'] . '">' :
    '<img src="/upload/images/no-image.png">';
$this->response->data['meta_title'] = 'Buy cheap ' . $page['meta_title'] . ' in our shop';

$this->response->script[] = '//somecdn.com/script.min.js';
$this->response->style[] = '//somecdn.com/style.css';

This code will create a thumbnail picture for product with sizes 250x250, change page title for seo and load the specified style to the script.

Note that a variable with a short name $page contains data from the $this->response->data at the time of initialization information block. Use it in the code.

 

Fast insert in content

Currently, this functionality is still under development, something that can change

If you want to add to iblock ability to embed visually in a couple of clicks, then in his folder, create a file manifest.ini with the contents like

[en]
title=Pages
description="List of pages, news or products"

[ru]
title=Страницы
description="Список страниц, новостей или товаров"

[data]
template=default
author=ArtyGrand

That is the name and a brief description of the information block in the desired language. After that, the button will appear in the rich text editor.




If you want to know something further - ask in the comments. The documentation will be complemented by your questions.
© Arthur Grand, 2011–2024
Powered by SyDES