CMS Development

Philip_Marsh
Mitwirkender/Mitwirkende

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

lösung

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 Akzeptierte Lösung
alyssamwilie
Lösung
Trendsetter/-in | Elite Partner
Trendsetter/-in | Elite Partner

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

lösung

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

Lösung in ursprünglichem Beitrag anzeigen

6 Antworten
alyssamwilie
Lösung
Trendsetter/-in | Elite Partner
Trendsetter/-in | Elite Partner

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

lösung

@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
Mitwirkender/Mitwirkende

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

lösung

Thank you. So simple. 

0 Upvotes
webdew
Ratgeber/-in | Diamond Partner
Ratgeber/-in | Diamond Partner

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

lösung

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
Mitwirkender/Mitwirkende

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

lösung

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
Autorität

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

lösung

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
Mitwirkender/Mitwirkende

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

lösung

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