Hi,
My goal is to list co-authors in any blog post.
Since HubSpot doesn’t have that inbuilt support, what I am trying to do is:
- Choice field with all Authors as options to choose from.
- Get Meta of Selected Author like Avatar, Slug, etc.
Once the co-author is selected via the choice field, my intention is to compare it against the authors’ list again so that I can get Author Avatar, Author Slug (I hope so). I am not concerned whether the co-author will be credited for the post, at the minimum I need some basic Author meta-data for display.
Example:
[
scr-1.png900x740 17.9 KB
For Choice field, I’ve tried the following code, but it not working.
{% set ta_authors = blog_authors('default', 250) %}
{% macro keyValues() %}
[{% for author in ta_authors %}[\"{{ author.id }}\", \"{{ author.display_name }}\"]{% if !loop.last %},{% endif %}{% endfor %}]
{% endmacro %}
{% set keyValues = keyValues() %}
{{ keyValues }}
{% choice "co_author" label='Select Co-Author', export_to_template_context=True, value='', choices='{{ keyValues }}' %}
The Choice list is not being populated. see: Screenshot by Lightshot
After, I tried to use static values in choice
{% choice "co_author" label='Select Co-Author', export_to_template_context=True, value='', choices='[[\"3457941083\", \"abbe vogels\"],[\"4756481638\", \"Alhad Akole\"]]' %}
The choice field is displaying choice and I can get the value of the selection.
Now, what I am trying to do to get author avatar and slug is
1. get all authors in sequence var all_auth
2. get the choice field value (auth id), var co_auth
3. loop through the sequence
for item in all_auth
if co_auth == item.id <-- get the author object
set co_auth = item <-- update the variable with the matched author object - possible typecasting issue
endif
endfor
4. Get co_auth.avatar & co_auth.slug
I am not having any luck in the iterative loop and if statement so far.
What I am trying to achieve is something like this
Screenshot by Lightshot
I just need the selected author from choice to be listed with Author Avatar, Slug so if someone clicks the URL he or she is able to find other live posts of the author.
Thanks in advance,

