# if else based on url or path

**URL:** <https://community.hubspot.com/t/if-else-based-on-url-or-path/35684>\
**Category:** CMS Development\
**Created:** [April 17, 2021, 7:58am UTC](https://community.hubspot.com/t/if-else-based-on-url-or-path/35684 "2021-04-17T07:58:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CarstenU](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/carstenu/32/89259_2.png) [@CarstenU](https://community.hubspot.com/u/CarstenU)\
**Post date:** [April 17, 2021, 7:58am UTC](https://community.hubspot.com/t/if-else-based-on-url-or-path/35684/1 "2021-04-17T07:58:58Z")

</div>

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 😉

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [April 19, 2021, 2:16pm UTC](https://community.hubspot.com/t/if-else-based-on-url-or-path/35684/2 "2021-04-19T14:16:04Z")

</div>

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:

```lia-code-sample
<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>

```
