I am having some trouble with the HubDB Selection field, my basic idea is when we add new data to the HubDB we select a 'Format' that format can either be a download, a course, a video etc... What I am wanting to do is display an icon depending on what has been selected in that column.
I'm trying to loop through the 'format' column for each row, check what the selection is and if it's 'Download' display a download icon, and so on and so forth.
Okay that's what I was thinking. By copy/paste my code you're looping inside an existing loop your created before. Replace all HubL code with this:
{% set table = hubdb_table_rows(3411941, queryparam) %}
<div class="rlpp-grid rlpp-grid-3col">
{% if table == [] %}
<p class='align-center' style="color: #2a2a2a; width: 100%;">Sorry, no listings found for that Search. Try changing your filter and search again.</p>
{% else %}
{% for row in table %}
<div class="resource-listing">
<a href=" {{ row["link"] }} " target="_blank" style="color: #fff;">
<div class="resource--format__icon">
{% if row.format.name|lower == "download" %}
<i class="fas fa-download">Icon</i>
// Other code like name and so on
{% else %}
// Other code like name and so on
{% endif %}
</div>
</a>
</div>
{% endfor %}
{% endif %}
</div>
From what I understand, you currently set a "Format" field which is a dropdown select. From this field, you want to retrieve what is the data selected from this field and show an icon if this is the case right?
Well, follow this kind of logic and it should work 🙂
{% set table = hubdb_table_rows(module.hubdbtable_field) %}
{% for row in table %}
{% if row.format.name|lower == "download" %}
// If format = download
{% else %}
// If format != download
{% endif %}
// Other code
{% endfor %}
Don't think that works, think you are on the right path though,
basically, I have a column in my hubdb where when we add new content you select either: Download, Article, Podcast, Video, Website, Course or Interview. On the resource (see below) I want to print an icon depending on what is selected.
I think the if condition to see if the name is download is right but that just prints 7 download icons rather than one because there are seven rows that have selected download.
This is the section of code for the resource listing part of the module, your addition is in bold.
<div class="resource-body"> {% set table = hubdb_table_rows(3411941, queryparam) %} <div class="rlpp-grid rlpp-grid-3col"> {% if table == [] %} <p class='align-center' style="color: #2a2a2a; width: 100%;">Sorry, no listings found for that Search. Try changing your filter and search again.</p> {% else %} {% for row in table %}
Okay that's what I was thinking. By copy/paste my code you're looping inside an existing loop your created before. Replace all HubL code with this:
{% set table = hubdb_table_rows(3411941, queryparam) %}
<div class="rlpp-grid rlpp-grid-3col">
{% if table == [] %}
<p class='align-center' style="color: #2a2a2a; width: 100%;">Sorry, no listings found for that Search. Try changing your filter and search again.</p>
{% else %}
{% for row in table %}
<div class="resource-listing">
<a href=" {{ row["link"] }} " target="_blank" style="color: #fff;">
<div class="resource--format__icon">
{% if row.format.name|lower == "download" %}
<i class="fas fa-download">Icon</i>
// Other code like name and so on
{% else %}
// Other code like name and so on
{% endif %}
</div>
</a>
</div>
{% endfor %}
{% endif %}
</div>