Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extending dataBlocks in twig templates #67

Open
clicktrend opened this issue Nov 17, 2020 · 0 comments
Open

Allow extending dataBlocks in twig templates #67

clicktrend opened this issue Nov 17, 2020 · 0 comments

Comments

@clicktrend
Copy link
Contributor

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 %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant