CMS Development

Philip_Marsh
投稿者

Print HubDB Multi-select value on Dynamic pages (Child pages)

解決

Hi,

I've used this post as a guide

https://community.hubspot.com/t5/CMS-Development/Printing-Values-from-HubDB-quot-Multi-Select-quot-c...

I've managed to get it to work with my main dynamic page. However, the issue I have is when it comes to the child pages.

The way I have my dynamic pages set us is, I have a category page, which links through to individual pages. The individual pages are generated for each row in the DB.

I have a "Presenters" column, which is a multi-selector. How do I only display the name value of a multi-selector from that individual row? Currently, this loops through all of the DB and outputs everything from the DB, rather than for that specific row.

 

{% for row in hubdb_table_rows(dynamic_page_hubdb_table_id, queryparam) %}

{% for category in row['presenters']%}<span class="presenter">{{ category.name }}</span>, {% endfor %}

{% endfor %}

 

0 いいね!
1件の承認済みベストアンサー
alyssamwilie
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Print HubDB Multi-select value on Dynamic pages (Child pages)

解決

@Philip_Marsh

You need to use the dynamic_page_hubdb_row tag, not table_id, to loop through the field to get each selected option.

{% for presenter in dynamic_page_hubdb_row.presenters %}
  <span class="presenter">{{ presenter.name }}</span>
{% endfor %}

 

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

元の投稿で解決策を見る

6件の返信
alyssamwilie
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Print HubDB Multi-select value on Dynamic pages (Child pages)

解決

@Philip_Marsh

You need to use the dynamic_page_hubdb_row tag, not table_id, to loop through the field to get each selected option.

{% for presenter in dynamic_page_hubdb_row.presenters %}
  <span class="presenter">{{ presenter.name }}</span>
{% endfor %}

 

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
Philip_Marsh
投稿者

Print HubDB Multi-select value on Dynamic pages (Child pages)

解決

Thank you. So simple. 

0 いいね!
webdew
ガイド役 | Diamond Partner
ガイド役 | Diamond Partner

Print HubDB Multi-select value on Dynamic pages (Child pages)

解決

Hi @Philip_Marsh ,

"
Use like this dynamic table:

{% if dynamic_page_hubdb_row %}
Detail page
{{ dynamic_page_hubdb_row.name }}

{% elif dynamic_page_hubdb_table_id %}

listing page:
{% for row in hubdb_table_rows(2899020, ""status__eq=Sold"") %}
<span>{{ row.name }}</span>
{% endfor %}
{% endif %}"

Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

0 いいね!
Philip_Marsh
投稿者

Print HubDB Multi-select value on Dynamic pages (Child pages)

解決

Hi, 

Thanks for the reply. I already have the dynamic template set up. The specific problem I'm having is to display the name value of the multi-select column on the individual pages. 

If I just use the below, as you suggest,:

 

{{ dynamic_page_hubdb_row.presenters }}

 

The out put is [{id=1, name='Steve', order=0}, {id=2, name='Emma', order=1}]

All I want to display is the name value. Adding .name displays nothing.

 

{{ dynamic_page_hubdb_row.presenters.name }}

 

0 いいね!
piersg
キーアドバイザー

Print HubDB Multi-select value on Dynamic pages (Child pages)

解決

Hi @Philip_Marsh, so you want to display a list of all the options that are in your mutli select? You want to use hubdb_table_columns and you have to add .options like so:

{% set presenters = hubdb_table_column(dynamic_page_hubdb_table_id, "presenters").options %}
{% for item in presenters %}
  <span class="presenter">{{ presenters.name }}</span>,
{% endfor %}

 

Philip_Marsh
投稿者

Print HubDB Multi-select value on Dynamic pages (Child pages)

解決

So, I have a column called presenters with 5 options:

  • Steve
  • Emma
  • Mark
  • Craig
  • Robert

I have a dynamic page set up that turns each row into a page.

In row 1, I have Steve and Emma selected

In row 2, I have Mark and Steve selected

On page 1, I only want to show Steve and Emma, and on Page 2 I want to only show Mark and Steve. 

My current code just looped through the entire database and would show as "Steve, Emma, Mark, Steve" regardless of what page you are on. It just loops through the entire database. 

I've tried your suggested code but as you said, it only prints out the available options for the multiple selector, not what has been selected

0 いいね!