CMS Development

kyl3
Colaborador(a)

updating dict with hubdb row value

resolver

I can't seem to find any documentation on how to convert a hubdb row value to a string that's suitable for the dictionary update function. It takes strings but nothing is working. Thanks

 

{% set menuLink_descs = {} %}
{% for row in hubdb_table_rows(3418393) %}
{% set key1 = row.name|string %}
{% set val1 = row.description|truncatehtml(100,'', false)|safe|string %}
{% set stupid = menuLink_descs.update({key1:val1}) %}
{% endfor %}

0 Avaliação positiva
1 Solução aceita
Kevin-C
Solução
Especialista reconhecido(a) | Parceiro
Especialista reconhecido(a) | Parceiro

updating dict with hubdb row value

resolver

Hey @kyl3 

 

So you can't dynamically set dict keys in Hubl.

Looking at your attempt leads me to wonder what you're trying to do with this dict?

 

Assuming you wont necessarily know the keys because they're dynamically created, maybe a list/array is a better fit?

{% set menuLink_descsdescs = [] %}

{% for row in hubdb_table_rows(3405985) %}
  {% do menuLink_descsdescs.append([row.name, row.description|truncatehtml(100,'', false)|safe|string]) %}
{% endfor %}
		
{{ menuLink_descsdescs }}

Now you can loop through you objects and reference your them with bracket notation!

 

Not sure if that helps at all but I hope so!

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

Exibir solução no post original

4 Respostas 4
Kevin-C
Solução
Especialista reconhecido(a) | Parceiro
Especialista reconhecido(a) | Parceiro

updating dict with hubdb row value

resolver

Hey @kyl3 

 

So you can't dynamically set dict keys in Hubl.

Looking at your attempt leads me to wonder what you're trying to do with this dict?

 

Assuming you wont necessarily know the keys because they're dynamically created, maybe a list/array is a better fit?

{% set menuLink_descsdescs = [] %}

{% for row in hubdb_table_rows(3405985) %}
  {% do menuLink_descsdescs.append([row.name, row.description|truncatehtml(100,'', false)|safe|string]) %}
{% endfor %}
		
{{ menuLink_descsdescs }}

Now you can loop through you objects and reference your them with bracket notation!

 

Not sure if that helps at all but I hope so!

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
kyl3
Colaborador(a)

updating dict with hubdb row value

resolver

I was needing to add a mega menu with text attached to a menu item and put them in hubdb. Wanting a quick lookup through a dict (associative array type) with it being 'link name:description' but sadly hubspot doesn't utilize this dynamically which I thought was possible in python. Is this a security measure? Seems to be a valuable tool to add eventually.

0 Avaliação positiva
Kevin-C
Especialista reconhecido(a) | Parceiro
Especialista reconhecido(a) | Parceiro

updating dict with hubdb row value

resolver

After sleeping on it, I'm pretty positive you could merge the data using hubl.

 

Maybe using the navigation menu text as a relational id and match it against a column in the HubDB?

 

If I get a chance today I'll try to explore this option!

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
Kevin-C
Especialista reconhecido(a) | Parceiro
Especialista reconhecido(a) | Parceiro

updating dict with hubdb row value

resolver

@kyl3 

 

I have done exactly this using the method above! But rather than attach the mega-menu to the menu-items I just built the whole menu in HubDB. Might be worth a shot?

Kevin Cornett - Sr. Solutions Architect @ BridgeRev