{# @var craft \craft\web\twig\variables\CraftVariable #} {# @var entry \craft\elements\Entry #} {# Content Builder Matrix ====================== Matrix Content Builder use the Core Matrix Field from Craft CMS #} {# -- Set Defaults -- #} {% set defaults = { cn: 'o-contentBuilder', modifiers: [], customClasses: [], object: entry ?? null, context: '12:24' } %} {# -- Merge Default with Options -- #} {% set opt = opt is defined ? defaults|merge(opt) : defaults %} {% if opt.object %} {# -- Colums Context -- #} {% set context = opt.context | split(':') %} {% set contextFirst = context[0] %} {% set contextLast = context[1] %}
{% if opt.object.contentBuilderMatrix|length %} {% set matrixfield = opt.object.contentBuilderMatrix.all() %} {% for content in matrixfield %} {% if loop.first and content.type != 'bkSection' %} {% include '_organisms/section/_template.html' with { opt: { modifiers: ['cb'], context: opt.context } } only %} {% endif %} {# Check if an other Section is opened and close the Section before #} {% if content.type == 'bkSection' %} {% if not loop.first %}
{% endif %} {% include '_contentBuilders/_contentBuilderModulesMatrix.html' with { data: content, context: opt.context } only %} {# All other Content Modules #} {% elseif content.type != 'bkSection' %} {% include '_contentBuilders/_contentBuilderModulesMatrix.html' with { data: content, context: opt.context } only %} {% endif %} {% endfor %} {% endif %} {% endif %}