if else based on url or path

Hi everyone.

I just want to display meeting date on different pages based at the url or path.

So I created a table with Datetime (termin) and a column (lernsequenz).

Date picks the date and the secound column is “lernsequenz” for each lesson. numbered like 1,2,3,…

My goal is to display on a page “/class-of-trading-1” the meeting date filtered by row.

In this case lernsequenz 1.

So the url matches the column.

This is the costum module code.

Is gives my no error, but it displays nothing in preview, also not in live mode.

<div class=“cm-termine”>

{% if request.path == ‘/class-of-trading-1/’ %}
{% set row in hubdb_table_rows(XXXXX, ‘lernsequenz=1’) %}
<h2> {{ row.termin|datetimeformat(‘%A, %d %B %Y um %H:%M Uhr’) }}</h2>
{% endif %}

{% if request.path == ‘/class-of-trading-2/’ %}
{% set row in hubdb_table_rows(XXXXX, ‘lernsequenz=2’) %}
<h2> {{ row.termin|datetimeformat(‘%A, %d %B %Y um %H:%M Uhr’) }}</h2>
{% endif %}
{% if request.path == ‘/class-of-trading-3/’ %}
{% set row in hubdb_table_rows(XXXXX, ‘lernsequenz=3’) %}
<h2> {{ row.termin|datetimeformat(‘%A, %d %B %Y um %H:%M Uhr’) }}</h2>
{% endif %}
</div>

any hints are helpful :wink:

hubdb_table_rows returns multiple rows so you need to loop over them using a for loop.

You could also cut the code you’ve written to a third by grabbing the ‘lernsequenz’ number you’re looking up from the URL e.g:

<div class="cm-termine">
{% if request.path is string_containing 'class-of-trading' %}
{% set num = request.path|cut('/class-of-trading-') %}
{% for rows in hubdb_table_rows(XXXXX, '&lernsequenz='~num) %}
 <h2> {{ row.termin|datetimeformat('%A, %d %B %Y um %H:%M Uhr') }}</h2>
{% endfor %}
{% endif %}
</div>