Skip to content

Allow extending dataBlocks in twig templates #67

Description

@clicktrend

For some reason it's very useful to allow extending dataBlocks in twig templates. For instance prepend to this set

{% set data = {
    'dataBlocks': dataBlocks,
} %}

this code

{% if data is defined and data.dataBlocks is defined %}
    {% set dataBlocks = dataBlocks|merge(data.dataBlocks) %}
{% endif %}

{% set data = {
    'dataBlocks': dataBlocks,
} %}

Then you can create your own twig template like this

{% extends '@!MarelloProduct/Product/view.html.twig' %}

{% block content_data %}
    {% set customBlock %}
        <div class="widget-content">
            Custom Block
        </div>
    {% endset %}
    {% set dataBlocks = [{
        'title' : 'Custom Block'|trans,
        'subblocks': [{
            'title' : null,
            'useSpan': false,
            'data' : [
                customBlock
            ]
        }]
    }] %}

    {% set data = {
        'dataBlocks': dataBlocks,
    } %}

    {{ parent() }}
{% endblock %}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions