The Main Schema—blocks.php in Venddor IO

Multilingual Support

The multilanguage parameter addresses whether a block requires language adaptability. If set to true, the block's content will be influenced by the current language, ensuring that users receive content in their preferred or set language.

>Overview

blocks.php acts as the foundational schema in Venddor IO's block management system. It's designed to map out the diverse block types that can be employed within the platform.

Structure

$schema = array(
    // A distinct identifier for each block type followed by its respective parameters
    'specific_block_type' => array(
        'settings' => array(),
        'templates' => array(),
        'cache' => array(),
        ...
    ),
);

Delving into Block Type Parameters

Settings (array)

This parameter holds the configurations of a block which can be adjusted on the block editing interface accessible through Design → Layouts → Block options.

A visual representation of a block's settings could look something like:

'settings' => array(
        'ip_address' => array(
            'type' => 'text',
            'default_value' => '127.0.0.1',
        ),
        ...
),

In this example, the setting ip_address is of the text type and its default value is set to '127.0.0.1'.

Block Setting Parameters Explained

Within the Venddor IO platform, block settings are highly customizable. These are the possible configurations:

Type (string)

Defines the setting's input method. Options include:

Other Parameters

Block Templates Explained

Templates in Venddor IO provide a structured representation for block displays. Here's a breakdown of the templates' configuration:

Templates (array)

Contains the list of potential templates. Each template is described as:

'path_to_template' => array (
  'settings' => 'List of specific settings',
  'fillings' => 'Available fillings for the template',
  'params' => 'Parameters for the block element retrieval function',
  'bulk_modifier' => 'A function affecting all block elements before display'
),

When Venddor IO generates a schema, the information from the block's template parameter incorporates settings from templates.php.

The template parameter in the block schema can be defined in several ways:

  1. Direct paths to templates with all associated settings
  2. Only paths to templates; further details are in templates.php
  3. The directory path having the templates; parameters are in templates.php
  4. A function's name returning template lists; settings are either in templates.php or the function itself

Wrappers Configuration

The wrappers segment within Venddor IO encompasses either an array list of wrappers or the directory path where these wrappers are stored. Distinctly, wrappers don't come with any additional configurable parameters.

Block Content Configuration

Blocks within Venddor IO can be filled with several variables, which are later passed to the respective template. Take this example:

'test_block' => array (
        'content' => array(
            'some_value' => array(
                'type' => 'text',
            )
        )
    )

Here, the admin panel displays a text input for block settings. In the user interface, this block's template will contain the {$some_value} variable, which admins can set.

Content can encompass settings (explained above), enumerations, or functions:

Cache Configuration

The cache segment defines caching policies for a block. Here's a breakdown of possibilities:

Cache Configuration Parameters

Update Handlers

The update_handlers parameter pertains to a list of database tables (omitting prefixes). Any changes to these tables, whether structural or data-wise, will refresh the block's cache. For instance, if a block presents a list of users, it would logically designate users and user_profiles as its update_handlers.

Key Generation for Cache Entries

The cache entry's key generation can incorporate serialized values of specific block parameters. To list necessary parameters, one can use:

Special notations like Dot-syntax can be used for nested elements, and * can be employed to select all values. Moreover, comparison operators such as gt, eq, in, ncont, etc., can be applied to fine-tune the conditions under which values are chosen.

Callable Handlers

The callable_handlers parameter encapsulates a list of parameters and their associated functions. The function's outcome serves as the value for the parameter when caching. For instance, using:

'callable_handlers' => array(
    'currency' => array('fn_get_secondary_currency'),
),

will append a segment like |currency=RUB to the cache key.

The function invoked is defined as: array(Callable[, Args]).

Where Callable represents a function or any expression that can be executed using call_user_func(). The Args parameter, though optional, lists arguments that the function will utilize. If an argument starts with $, it's perceived as a variable name, specifically if it's a global variable or belongs to $block_schema and $block_data.

Disabling Cache Logic

The disable_cache_when parameter details conditions under which block caching is disabled. While parameters like request_handlers and auth_handlers can be the same as in the cache settings, their function differs:

Cache Invalidation Logic

regenerate_cache_when provides rules for cache invalidation of the block and operates similarly to disable_cache_when.

Cache Overrides by Dispatch

cache_overrides_by_dispatch allows for setting distinct cache parameters based on dispatch. If a particular dispatch is defined in this setting, cache specifics for that dispatch will override any general block caching settings. This is useful for having fine-grained cache behaviors for different site areas or functionalities.

Block Visibility Constraints

With hide_on_locations, developers can pinpoint dispatches where a block shouldn't appear. For instance, to prevent a block from appearing on the shopping cart page, one would use hide_on_locations with a value like checkout.cart.

Single Block Constraint

The single_for_location boolean parameter ensures that a specific dispatch only contains one instance of the block type. By default, it's set to false, meaning multiple block instances can be placed on a dispatch.