Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Cinema site: selecting movies through dates

Started by Muut Archive 11 years ago · 0 replies · 666 views
11 years ago

this is the layout file:

TWIG
{% extends 'partials/base.html.twig' %}

{% block content %}

  {% import "partials/macros/movie_macros.html.twig" as movie_macros %}

  {% set all_movies = page.find('/movies').collection %}

  {{ movie_macros.return_current_movies(all_movies) }}

{% endblock %}

and this is the macro!

TWIG
{% macro return_current_movies(all_movies) %}

  {% set current_year = now|date("Y") %}
  {% set current_month = now|date("n") %}
  {% set current_day = now|date("j") %} 

  <div class="movies">
    {% for each_movie in all_movies %}

      {% if each_movie.header.active == true %}
        {% for each_show in each_movie.header.shows %}

          {% set show_year = each_show.date|date("Y") %}
          {% set show_month = each_show.date|date("n") %}
          {% set show_day = each_show.date|date("j") %}

        {% endfor %}
      {% endif %}

    {% endfor %}
  </div>

{% endmacro %}

I'd like to return a collection of movies that are currently running (this day, last week, this week and next week) ... thanks!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 672 1 week ago
Archive · by Deleted User, 9 years ago
0 3042 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5336 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago