Tips, Tricks & Best Practices

wmflan39
Contributor

Error in my HubL code; please help!

SOLVE

On our one of our staging pages (*link removed due to security reasons)  I use accordions to present product listings from our 'lenses' HubDB ID 5307563. All column 1 and most of column 2 accordions work as expected, sample code per:

 

<div>{% set table_id = 5307563%}</div>
<div>{% for row in hubdb_table_rows(5307563,'class__contains=Pinhole') %} <img src="https://f.hubspotusercontent40.net/hubfs/20881091/images/{{ row.filename }}.jpg" data-constrained="true" style="float: right; display: inline-block; width: 200px; padding-top: 20px;">
<p>Model: {{ row.model_no }}<br>MTF: <a href="https://f.hubspotusercontent40.net/hubfs/20881091/pdfs/mtf-{{ row.filename }}.pdf" rel="noopener">{{ row.filename }}</a><br>Focal Length (mm): {{ row.focal_length }}<br>Aperature (f): {{ row.aperature }}<br>Back Focal Length (mm): {{ row.back_focal }}<br>Sensor: {{row.sensor }}<br>Field of View (deg): {{ row.field_of_view }}</p>
<div>Request: <a href="/data-sheet-request?interest=lenses&amp;document_filename=pds-{{ row.filename }}.pdf&amp;document_title={{ row.name }}&amp;part_number={{ row.name }}">{{ row.name }}</a></div>
<hr>{% endfor %}</div>

 

where rows are selected by 'class'. The last 2 accordion sections in column 2 (CS - 3MP & M14 - VF) cheerfully refuse to display the required content. Sample code:

 

<div>{% set table_id = 5307563%}</div>
<div>{% for row in hubdb_table_rows(5307563,'class__contains=CS - 3MP') %} <img src="https://f.hubspotusercontent40.net/hubfs/20881091/images/{{ row.filename }}.jpg" data-constrained="true" style="float: right; display: inline-block; width: 200px; padding-top: 20px;">
<p>Model: {{ row.model_no }}<br>MTF: <a href="https://f.hubspotusercontent40.net/hubfs/20881091/pdfs/mtf-{{ row.filename }}.pdf" rel="noopener">{{ row.filename }}</a><br>Focal Length (mm): {{ row.focal_length }}<br>Aperature (f): {{ row.aperature }}<br>Back Focal Length (mm): {{ row.back_focal }}<br>Sensor: {{row.sensor }}<br>Field of View (deg): {{ row.field_of_view }}</p>
<div>Request: <a href="/data-sheet-request?interest={{ row.product }}&amp;document_filename=pds-{{ row.filename }}.pdf&amp;document_title={{ row.name }}&amp;part_number={{ row.name }}">{{ row.name }}</a></div>
<hr>{% endfor %}</div>

 

Rows with classes 'CS - 3MP' and 'M14 - VF' exist in the HubDB, yet these refuse to display. I have taken several steps to trouble-shoot but nothing works.

Is there anything obvious in what I'm doing wrong?

WmFlanigan

0 Upvotes
1 Accepted solution
stefen
Solution
Key Advisor | Partner
Key Advisor | Partner

Error in my HubL code; please help!

SOLVE

@wmflan39 you might want to try url escaping the spaces e.g.:

 

{% for row in hubdb_table_rows(5307563,'class__contains=CS%20-%203MP') %}

 


Another thing to note is that the contains filter when used with a multiselect column returns rows that contain all of the supplied values.

Stefen Phelps, Community Champion, Kelp Web Developer

View solution in original post

4 Replies 4
wmflan39
Contributor

Error in my HubL code; please help!

SOLVE

Stefan, thanks for replying.

I have tried to isolate the problem by moving code from one of the working accordions into the offending accordion: success.

Then editing the 'class' filter in the code transplanted to the offending accordion to display the product class 'M12 - 10MP' from

{% for row in hubdb_table_rows(5307563,'class__contains=M12 - 10MP') %}

to

{% for row in hubdb_table_rows(5307563,'class__contains=CS - 3MP') %}

 ...trying to display the product class 'CS - 3MP'. Result: fail.  Must be something with the DB. I've deleted the row for the offending single record for CS - 3MP and re-entered the data manually: fail.

 

I'm not sure what you mean by the schema of the table. The class column is a multi-select contining ~20 entries. All other columns are text fields.

 

How can I better answer your question?

 

WmF

stefen
Solution
Key Advisor | Partner
Key Advisor | Partner

Error in my HubL code; please help!

SOLVE

@wmflan39 you might want to try url escaping the spaces e.g.:

 

{% for row in hubdb_table_rows(5307563,'class__contains=CS%20-%203MP') %}

 


Another thing to note is that the contains filter when used with a multiselect column returns rows that contain all of the supplied values.

Stefen Phelps, Community Champion, Kelp Web Developer
stefen
Key Advisor | Partner
Key Advisor | Partner

Error in my HubL code; please help!

SOLVE

@wmflan39 it's kind of hard to understand what's going on here. Are you able to make a reduced test case? And possibly the structure/schema of the hubdb table?

Stefen Phelps, Community Champion, Kelp Web Developer
PamCotton
HubSpot Alumni
HubSpot Alumni

Error in my HubL code; please help!

SOLVE

Hello @wmflan39 I would like to add some top experts to this matter to share their ideas, @psdtohubspot @stefen any recommendations to @wmflan39 matter?

 

Thank you,

Pam