{# HOWTO Sections # The biggest feature of sections is the autowrapper. This autowrapper will take care of all needed 'container, 'row' and 'col' divs. The calling template # does not need to set it's own 'container, 'row' and 'col' wrappers. # # In practice, all a section needs to do is specify it's desired colclass (if diferent from the default) and if it has # room enough for a ad slot (Default is true). # # The logic behind the autowrapper in detail is as follows, if it is enabled: # On opening a new section, the current column and container classes are compared to the ones from the last section. If the last section # had a different column or container class, the 'container, 'row' and 'col' divs will be closed (if any) and a new # 'container, 'row' and 'col' div with the new desired classes will be opened. # If a col is closed and the former section did allow advertisements, the autowrapper will also add a advertisement # slot before closing the row. # Also, the last section will also close the col and row classes (with adding advertisements) if autoclose is enabled. # # See variable descriptions below: # sections_variant - the template variant for the section container classes (REQURIED) # sections_autowrapper_enabled - Enable or diable the auto opening/closing feature of the autowrapper # sections_autowrapper_colclass - the default column class for all sections that did not specify something themselfes # sections_autowrapper_colclass_default - the fallback column class for all sections without any sections_autowrapper_colclass # (We need a _default variable in addition to that above to alow page templates to specify a default for any # section template that did not specify something later.) # sections_autowrapper_autoclose - Enable or disable automatic closing of col row divs after last section # Sample options - Narrow text section allowing an adslot: # {% set options = options|default({}) + { # sections_variant: 'text', # sections_autowrapper_colclass: 'col-md-8', <- can be omitted as it's the default # } %} # # Sample options - Wide image without adslot # {% set options = options|default({}) + { # sections_variant: 'image', # sections_autowrapper_colclass: 'col-12', # sections_autowrapper_containerclass: 'container-fluid', # } %} #} {% set options = options|default({}) + { sections_type: 'default', sections_variant: '', sections_container_class: '', sections_autowrapper_enabled: true, sections_autowrapper_colclass_default: 'col-12 col-md-8 offset-md-2 col-lg-12 offset-lg-0', sections_autowrapper_rowclass: 'row', sections_autowrapper_containerclass: 'container', sections_autowrapper_autoclose: true, sections_autowrapper_aside_colclass: 'col-12 col-md-6', sections_autowrapper_behavior: 'half', sections_autowrapper_wrapperclass: false, sections_autowrapper_forcerow: false, } %} {# set options for colclass based on the autowrapper behavior #} {% if options.sections_autowrapper_behavior == 'full' %} {% set options = options + { sections_autowrapper_colclass: 'col-12 full' } %} {% endif %} {% if options.sections_autowrapper_behavior == 'half' %} {% set options = options + { sections_autowrapper_colclass: options.sections_autowrapper_colclass_default } %} {% endif %} {% if options.sections_autowrapper_behavior == 'aside' %} {% set options = options + { sections_autowrapper_colclass: 'col-12 col-md-6' } %} {% endif %} {% set options = options + { sections_autowrapper_colclass: options.sections_autowrapper_colclass_default, } %} {% set section_active = true %} {# We set the section here as variable, because we need it as a normal and aside section #} {% set section %}
{% block section_content %}{% endblock %}
{% endset %} {# The autowrapper breaks down row and col divs surrounding it, if the current col and offset dont match the needed ones for this section #} {% if options.sections_autowrapper_enabled %} {% set res = section_state.init('autowrapper_current_behavior', '') %} {% set res = section_state.init('autowrapper_wrapperclass', false) %} {# If current container is present but doesnt match > close col and row divs #} {% if section_state.autowrapper_current_behavior and section_state.autowrapper_current_behavior != options.sections_autowrapper_behavior or options.sections_autowrapper_forcerow %} {% include 'sections/default/_base/_closer.twig' %} {% endif %} {# If current container doesnt match > open new col and row divs #} {% if section_state.autowrapper_current_behavior != options.sections_autowrapper_behavior or options.sections_autowrapper_forcerow %} {% if options.sections_autowrapper_behavior == 'aside' %} {% set section_active = false %} {% set options = { sections_autowrapper_behavior: 'half' } + options %} {% endif %} {% include 'sections/default/_base/_opener.twig' with { aside: not section_active } %} {% endif %} {# set new opened class #} {% set res = section_state.set('autowrapper_current_behavior', options.sections_autowrapper_behavior) %} {% endif %} {% if section_active %} {{ section }} {% endif %} {# If current container is last one > close #} {% if options.sections_autowrapper_enabled and options.sections_autowrapper_autoclose and section_last %} {% include 'sections/default/_base/_closer.twig' %} {% endif %}