Display individual columns from one HubDB table row
I have created an employee listing page from a HubDB table and wish to display the details of each employee on a separate detail page. For the life of me I cannot find anything in the documentation that explains how to do this. Everything only shows how to list everything in a table. I only want to show one row of a table on a page.
Display individual columns from one HubDB table row
Have you put values in the hs_name and hs_path columns (unique for each row)? Just checking 🙂
If so, try it the other way round, testing if the user is viewing a dynamically created sub-page (row) before the listing page (table), see if that works:
{% if dynamic_page_hubdb_row %}
{# detail page #}
{% set row = dynamic_page_hubdb_row %}
<h1>{{ row.hs_name }}</h1>
<p>{{ row.name }}</p>
<p>{{ row.position }}</p>
{% elif dynamic_page_hubdb_table_id %}
{# listings page #}
{% set table_id = dynamic_page_hubdb_table_id %}
{% set table = hubdb_table_rows(table_id) %}
{% if table == [] %}
<p>Sorry, something went wrong!</p>
{% else %}
{# all employees #}
{% for row in table|sort(False, False, 'name') %}
<p>{{row.name}}</p>
{% endfor %}
{% endif %}
[% endif %}
Display individual columns from one HubDB table row
Hi @DChadney, have you enabled the settings in the HubDB to do this? Go to Actions > Manage settings and make sure "Enable creation of dynamic pages using row data" is on. This will add two extra columns to you DB, Page title (as in meta title) and Page path (as in URL path).
Display individual columns from one HubDB table row
@piersg Yes this is already enabled and the two columns hs_name and hs_path are present. I'm just new to Hubl and not sure how to set up the code to show individual rows.