relatedpages.html.twig 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. {% macro recursivePages(amount, page, page1, page2) %}
  2. {% import _self as self %}
  3. {% set index = amount - 1 %}
  4. {% if index >= 0 %}
  5. {% set random_utilite = random(page.find('/projets').children) %}
  6. {% set p = random(random_utilite.children) %}
  7. {% if not page1 %}
  8. {% if p == page %}
  9. {% set index = amount + 1 %}
  10. {{ self.recursivePages(index, page) }}
  11. {% else %}
  12. {% include 'partials/projet_card.html.twig' with { p } %}
  13. {{ self.recursivePages(index, page, p) }}
  14. {% endif %}
  15. {% elseif not page2 %}
  16. {% if p == page or p == page1 %}
  17. {% set index = amount + 1 %}
  18. {{ self.recursivePages(index, page, page1) }}
  19. {% else %}
  20. {% include 'partials/projet_card.html.twig' with { p } %}
  21. {{ self.recursivePages(index, page, page1, p) }}
  22. {% endif %}
  23. {% elseif not page3 %}
  24. {% if p == page or p == page1 or p == page2 %}
  25. {% set index = amount + 1 %}
  26. {{ self.recursivePages(index, page, page1, page2) }}
  27. {% else %}
  28. {% include 'partials/projet_card.html.twig' with { p } %}
  29. {% endif %}
  30. {% endif %}
  31. {% endif %}
  32. {% endmacro %}
  33. {% import _self as self %}
  34. <div id="related-pages">
  35. <hr>
  36. <h3>Voir aussi</h3>
  37. <div id="related-grid">
  38. {% set relatedAmount = 3 %}
  39. {{ self.recursivePages(relatedAmount, page) }}
  40. </div>
  41. <p><a href="{{ page.parent.parent.url }}">Retour à la liste des projets</a></p>
  42. </div>