Through {{post}} I am displaying all post data through hubdb. But I need to output the author and everything related to it. How do I connect the output?
The second problem is displaying posts by tags. Example: 1 block - tag = “Video”, 2 block of posts tag “News”, 3 block of posts “Music”.
Is there a way to output this via macros?
{% for single_row in module.blog_section %}
{% set table = hubdb_table_rows(single_row.hubl_table, 'limit='~ single_row.post_limit ~'&orderBy=-hs_created_at') %}
{% for row in table %}
{% set post = content_by_id(row['post_id']) %}
{% set my_authors = blog_authors(blog, tag, limit) %}
{% for author in my_authors %}
{{ do post.append(author) }}
{% endfor %}
<div style="border: 1px solid gray; margin-bottom: 20px">
{{ post }}
</div>
{% endfor %}
{% endfor %}
@Anton ,
How would you solve for this?
{% macro post(url, src, title, avatar, author, bio, date, text, customClass) %}
<div class="item {{ customClass }}">
<a class="inline" href="{{ url }}" target="_blank">
<div class="wrapper" style="position: relative; padding-bottom: 69.33%;">
<div class="img"><img loading="lazy" class="lazyload" data-src="{{ src }}"
src="{{ module_asset_url("px-to-px--white.png") }}" alt="post image"
style="position: absolute; width: 100%; height: 100%; display: block; object-fit: cover;"></div>
</div>
<div class="information">
<div class="title size--m">
{{ title|truncate(54, false, '...') }}
</div>
<div class="author">
<div class="icon" style="height: 52px; width: max-content;">
<img src="{{ avatar }}" style="width: 100%; height: 100%; object-fit: contain;">
</div>
<div class="author-info">
<div class="name title size--s-bold">
{{ author }}
</div>
<div class="text size--s-r">
{{ bio }}
</div>
</div>
</div>
{% if single_row.tag_filter == 'B2B' %}
<div class="ref" style="margin-top: 28px">
<div class="ref__link size--l-m">
Watch on Demand
</div>
</div>
{% endif %}
</div>
</a>
</div>
{% endmacro %}
<div class="blog-post">
<div class="container">
{% for single_row in module.blog_section %}
{% set blog_id = '5669832573'%}
{% set blog_post = blog_recent_tag_posts(blog_id, single_row.tag_filter, single_row.post_limit) %}
{% set my_authors = blog_authors(blog_id, single_row.tag_filter, single_row.post_limit) %}
<div class="row row--light row__tag {{ single_row.tag_filter }}">
<div class="col-12 px-md-0">
<a class="heading info col-12{% if single_row.title.view %} hidden{% endif %}"
href="{{ single_row.title.link.href }}">
<img src="{{ single_row.title.icon.src }}" alt="{{ single_row.title.icon.alt }}">
<span class="title size--l">
{% inline_text field="title.title" value="{{ single_row.title.title }}" %}
</span>
</a>
<div class="row list">
{% for i in blog_post %}
{% if loop.index > 3 %}
{% set cssClass = "hidden mt-5 col-md-6 col-lg-4" %}
{% elif loop.last %}
{% else %}
{% set cssClass = "col-md-6 col-lg-4" %}
{% endif %}
{{ post(i.absolute_url, i.featured_image, i.name, i.blog_post_author.avatar, i.blog_post_author.display_name, i.blog_post_author.bio, i.publish_date_local_time|datetimeformat('%B %e, %Y'), i.post_body|striptags|truncate(96, True, '...'), cssClass) }}
{% endfor %}
</div>
{% if loop.length < 3 %}
<div class="d-flex justify-content-center w-100">
<a href="#form-top" target="_blank" class="more-btn more-btn--border col-auto mx-auto load-more">
<span>Load More</span>
</a>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>