Answer the question
In order to leave comments, you need to log in
How to duplicate a file in a PHP loop and output to the main Twig template?
There is a template:
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<center>
{{ repositories.name }}
</center>
</div>
<div class="panel-body">
<center>
<p id="version">Версия: 1.0.10 Alpha</p>
<div id="buttons">
<a href="#" class="btn btn-success">Скачать</a>
<a href="#" class="btn btn-info">Подробнее</a>
</div>
</center>
</div>
</div>
</div>
{% extends "base.layout" %}
{% block title %} Главная {% endblock title %}
{% block content %}
<center>
<h1>Репозитории</h1>
</center>
<hr />
<!-- Repositories -->
{{ repos }}
<!-- end repositories -->
{% endblock content %}
{% extends "base.layout" %}
{% block title %} Главная {% endblock title %}
{% block content %}
<center>
<h1>Репозитории</h1>
</center>
<hr />
<!-- Repositories -->
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<center>
Title
</center>
</div>
<div class="panel-body">
<center>
<p id="version">Версия: 1.0.10 Alpha</p>
<div id="buttons">
<a href="#" class="btn btn-success">Скачать</a>
<a href="#" class="btn btn-info">Подробнее</a>
</div>
</center>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<center>
Title
</center>
</div>
<div class="panel-body">
<center>
<p id="version">Версия: 1.0.10 Alpha</p>
<div id="buttons">
<a href="#" class="btn btn-success">Скачать</a>
<a href="#" class="btn btn-info">Подробнее</a>
</div>
</center>
</div>
</div>
</div>
<!-- end repositories -->
{% endblock content %}
Answer the question
In order to leave comments, you need to log in
Try it with the filter
twig.sensiolabs.org/doc/advanced.html
it should look something like this
....
// регим фильтр в твиге
$filter = new \Twig_SimpleFilter('dublicate', function($repo){
return str_repeat($repo,2); // здесь для дублирования можешь использовать и цикл если тебе сильно надо
}, array('is_safe' => array('html');
$this->twig->addFilter($filter);
.....
{% extends "base.layout" %}
{% block title %} Главная {% endblock title %}
{% block content %}
<center>
<h1>Репозитории</h1>
</center>
<hr />
<!-- Repositories -->
{{ repos|dublicate }}
<!-- end repositories -->
{% endblock content %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question