CMS Development

Philip_Marsh
Contributor

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

SOLVE

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 Upvotes
1 Accepted solution
amwilie
Solution
Key Advisor | Elite Partner
Key Advisor | Elite Partner

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

SOLVE

@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!

border

Alyssa Wilie

Web Developer at LyntonWeb

Kickstart your success on HubSpot's CMS with a theme by the HubSpot experts at Lynton


View solution in original post

6 Replies 6
amwilie
Solution
Key Advisor | Elite Partner
Key Advisor | Elite Partner

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

SOLVE

@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!

border

Alyssa Wilie

Web Developer at LyntonWeb

Kickstart your success on HubSpot's CMS with a theme by the HubSpot experts at Lynton


Philip_Marsh
Contributor

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

SOLVE

Thank you. So simple. 

0 Upvotes
webdew
Guide | Diamond Partner
Guide | Diamond Partner

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

SOLVE

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 Upvotes
Philip_Marsh
Contributor

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

SOLVE

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 Upvotes
piersg
Key Advisor

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

SOLVE

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
Contributor

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

SOLVE

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 Upvotes