Foreign IDs in multilevel dynamic page template populating all rows

@NWonders which level is which in your logic?

Just had a quick read of this and it seems for multi level pages, you should be using the hs_child_table_id variable to get the child table values of your row:

{% if dynamic_page_route_level == 0 %}
	<h1>Categories</h1>
 {% set rows = hubdb_table_rows(dynamic_page_hubdb_table_id) %}
 {% for row in rows %}
 	<h2><a href="{{ request.path }}/{{ row.hs_path }}">{{ row.hs_name }}</a></h2>
 	{% set childRows = hubdb_table_rows(row.hs_child_table_id) %}
 	{% for childRow in childRows %}
 	<li><a href="{{ request.path }}/{{ row.hs_path }}/{{childRow.hs_path}}">{{ childRow.hs_name }}</a></li> 
 	{% endfor %} 
 {% endfor %}
{% endif %}

I gave it a try and it seems to work fine.

Remember that child pages aren’t generated via foreign ID columns.

Level 0 is the main page (one where you select the hubdb for the page)

Level 1 is the first hubdb level

Level 2 s the child table of level 1

Everything in each child level are items belonging to the parent level, i.e every item in level 2 is a subpage of level 1.

I’ve tried this on my end:

{% if dynamic_page_route_level == 0 %}
{% set rows = hubdb_table_rows(dynamic_page_hubdb_table_id) %}
<ul>
 {% for row in rows %}
 {% set childRows = hubdb_table_rows(row.hs_child_table_id) %}
 {% for childRow in childRows %}
 <li><a href="{{ request.path }}/{{ row.hs_path }}/{{childRow.hs_path}}">{{ childRow.name }}</a></li> 
 {% endfor %} 
 {% endfor %}
</ul>
{% elif dynamic_page_route_level == 1 %}
{{ dynamic_page_hubdb_row.level_1_items}}
{% elif dynamic_page_route_level == 2 %}
{{ dynamic_page_hubdb_row.level_2_items}}
{% endif %}

and everything shows up as intended. (level_1_items and level_2_items are the foreign columns I added)

Or am I misunderstanding your logic?