{# 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 # sections_autowrapper_adslot_allowed - Indicates, if this section is narrow enough to show an adslot on the right # sections_autowrapper_adtemplate - the template to use for the adslot (See required options there) # sections_autowrapper_adcolclass - the default column class for the col div containing the ad slot # # 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 # sections_autowrapper_adslot_allowed: true, <- 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_adslot_allowed: false, # 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-md-8 col-lg-7 offset-lg-1 col-xl-6 offset-xl-2', sections_autowrapper_rowclass: 'row', sections_autowrapper_containerclass: 'container', sections_autowrapper_autoclose: true, sections_autowrapper_adslot_allowed: true, sections_autowrapper_adslot: 'rail', sections_autowrapper_adcolclass: 'col-md-4 text-center', } %} {% set options = options + { sections_autowrapper_colclass: options.sections_autowrapper_colclass_default, } %} {# 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 %} {% block section_autowrapper_prefix %} {% set res = section_state.init('autowrapper_current_comparehash', '') %} {% set res = section_state.init('autowrapper_current_adslot_allowed', true) %} {% set comparehash = options.sections_autowrapper_containerclass ~ '|' ~ options.sections_autowrapper_colclass %} {# If current container is present but doesnt match > close col and row divs #} {% if section_state.autowrapper_current_comparehash and section_state.autowrapper_current_comparehash != comparehash %} {% include 'sections/default/_base/_closer.twig' %} {% endif %} {# If current container doesnt match > open new col and row divs #} {% if section_state.autowrapper_current_comparehash != comparehash %} {% include 'sections/default/_base/_opener.twig' %} {% endif %} {# set new opened class #} {% set res = section_state.set('autowrapper_current_comparehash', comparehash) %} {% set res = section_state.set('autowrapper_current_adslot_allowed', options.sections_autowrapper_adslot_allowed) %} {% endblock %} {% endif %}
{% block section_content %}{% endblock %}
{% if options.sections_autowrapper_enabled and options.sections_autowrapper_autoclose %} {% block section_autowrapper_suffix %} {# If current container is last one > close #} {% if section_last %} {% include 'sections/default/_base/_closer.twig' %} {% endif %} {% endblock %} {% endif %}