CMS Development

kyl3
投稿者

updating dict with hubdb row value

解決

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 いいね!
1件の承認済みベストアンサー
Kevin-C
解決策
名誉エキスパート | Solutions Partner
名誉エキスパート | Solutions Partner

updating dict with hubdb row value

解決

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

元の投稿で解決策を見る

4件の返信
Kevin-C
解決策
名誉エキスパート | Solutions Partner
名誉エキスパート | Solutions Partner

updating dict with hubdb row value

解決

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
投稿者

updating dict with hubdb row value

解決

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 いいね!
Kevin-C
名誉エキスパート | Solutions Partner
名誉エキスパート | Solutions Partner

updating dict with hubdb row value

解決

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
名誉エキスパート | Solutions Partner
名誉エキスパート | Solutions Partner

updating dict with hubdb row value

解決

@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