Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

Cinema site: selecting movies through dates

Started by Muut Archive 10 years ago · 0 replies · 252 views
10 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 Deleted User, 9 years ago
0 1279 9 years ago
Archive · by Muut Archive, 9 years ago
2 886 9 years ago
Archive · by Muut Archive, 9 years ago
2 4015 9 years ago
Archive · by Muut Archive, 9 years ago
1 2891 9 years ago
Archive · by Muut Archive, 9 years ago
3 1075 9 years ago