Question

How to adapt this code in php for Drupal 7?

https://jimbir.ch/blog/making-multi-column-content-section-drupal-paragraphs-bootstrap

drupal-paragraph-multi-column-field.html.twig
{% for item in items %}
<div class="col-sm-{{ 12 // loop.length }}">{{ item.content }}</div>
{% endfor %}
Was it helpful?

Solution

I placed this code in field--[field name].tpl.php

    <?php foreach ($items as $delta => $item) : ?>
       <div class="col-sm-<?php print round(12/count($items)); ?>">
        <?php print render($item); ?>
         </div>
<?php endforeach; ?>

It seems to work !

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top