Skip to content
Snippets Groups Projects
views-bootstrap-grid.html.twig 1.71 KiB
Newer Older
bcweaver's avatar
bcweaver committed
{#
/**
 * @file views-bootstrap-grid.html.twig
 * Default simple view template to display Bootstrap Grids.
 *
 *
 * - columns: Contains rows grouped by columns.
 * - rows: Contains a nested array of rows. Each row contains an array of
 *   columns.
 * - column_type: Contains a number (default Bootstrap grid system column type).
 *
 * @ingroup views_templates
 */
#}
{%
  set classes = [
    'views-view-grid',
    options.alignment,
  ]
%}
{% if title %}
  <h3>{{ title }}</h3>
{% endif %}
bcweaver's avatar
bcweaver committed
<div id="{{ id }}" {{ attributes.addClass(classes) }}>
  {% if options.alignment  == 'horizontal' %}
    {% for row in items %}
      <div class="row">
        {% for column in row.content %}
          <div class="col {{ col_xs }} {{ col_sm }} {{ col_md }} {{ col_lg }} {{ options.row_class }}">
            {{ column.content }}
          </div>
        {% endfor %}
      </div>
    {% endfor %}
  {% else %}
    <div class="row">
      {% for column in items %}
        <div class="col {{ col_xs }} {{ col_sm }} {{ col_md }} {{ col_lg }} {{ options.row_class }}">
          {% for row in column.content %}
            {{ row.content }}
          {% endfor %}
        </div>

        {% if loop.index is divisible by (sizes.xs) %}
          <div class="clearfix visible-xs-block"></div>
        {% endif %}

        {% if loop.index is divisible by (sizes.sm) %}
          <div class="clearfix visible-sm-block"></div>
        {% endif %}

        {% if loop.index is divisible by (sizes.md) %}
          <div class="clearfix visible-md-block"></div>
        {% endif %}

        {% if loop.index is divisible by (sizes.lg) %}
          <div class="clearfix visible-lg-block"></div>
        {% endif %}
      {% endfor %}
    </div>
  {% endif %}
</div>