Hello HubSpot Developer Community, hoping for a learning experience for this newbie…
The default module Logo Grid (theme Brightlane) doesn’t let you add URL links to the logos. I’m trying to add in the code to do this and I can’t get it to work.
Here’s the original code:
{% set logos = module.group_logos %}
{% set grid_settings = module.styles.group_logo_grid %}
{% set logo_styles = module.styles.group_logo %}
{% set grid_basis_spacing = grid_settings.grid_gap - (grid_settings.grid_gap / grid_settings.column_count) %}
{% set column_count_percentage = ((1 / grid_settings.column_count) * 100) ~ “%” %}
{% macro add_style_if_value(style, field, unit = “”) %}
{% set field_with_unit = field ~ unit %}
{{ style }}: {{ field_with_unit }};
{% endmacro %}
{% require_css %}
<style>
@Layer module {
{% scope_css %}
.hs-logo-grid {
gap: {{ grid_settings.grid_gap ~ “px” }};
}
.hs-logo-grid__logo-wrapper {
flex: 0 1 calc({{ column_count_percentage }} - {{ grid_basis_spacing ~ “px” }});
max-width: calc({{ column_count_percentage }} - {{ grid_basis_spacing ~ “px” }});
{{ add_style_if_value(“aspect-ratio”, logo_styles.group_background.aspect_ratio) }}
{{ add_style_if_value(“background-color”, logo_styles.group_background.background_color.css ) }}
{{ logo_styles.group_spacing.padding.css }}
}
.hs-logo-grid__logo {
max-height: {{ logo_styles.max_logo_height ~ “px” }};
}
{% end_scope_css %}
}
</style>
{% end_require_css %}
{% macro build_image(image) %}
{% if image.src %}
{% set sizeAttrs = ‘width=“{{ image.width }}” height=“{{ image.height }}”’ %}
{% set loadingAttr = image.loading != ‘disabled’ ? ‘loading=“{{ image.loading }}”’ : ‘’ %}
<img class=“hs-logo-grid__logo” src=“{{ image.src }}” alt=“{{ image.alt }}” {{ loadingAttr }} {{ sizeAttrs }}>
{% endif %}
{% endmacro %}
{% macro build_logo_grid() %}
{% for item in logos %}
<div class=“hs-logo-grid__logo-wrapper”>
{{ build_image(item.logo) }}
</div>
{% endfor %}
{% endmacro %}
<div class=“hs-logo-grid”>
{{ build_logo_grid() }}
</div>
---
I added in the new Link Field variable already ‘link_url’. With options to link to External/Content/File/Blog/etc.
When I tried adding in a href into the build_image it didn’t work as I expected.
Can someone help me get my new field referenced within the HTML so it actually does something?
