Hi all,
{% if dynamic_page_crm_object %}
<details>
<summary>
<h5>Research Publications</h5>
<div class="chevron-icon"></div>
</summary>
<div class="content-wrapper">
{% set publication_types = [ {'type': 'Book', 'heading': 'Books', 'info': "{{ ac_profiles.name_of_author_s_ }} ({{ ac_profiles.year_published }}). <em>{{ ac_profiles.publication_title }}</em>. {{ ac_profiles.books_book_chapters_music__publisher_name_and_place }}<br>"}, {'type': 'Book chapter', 'heading': 'Book Chapters', 'info': "{{ ac_profiles.name_of_author_s_ }} ({{ ac_profiles.year_published }}). <em>{{ ac_profiles.publication_title }}</em> in {{ ac_profiles.book_chapter__book_name }} (pp.{{ ac_profiles.book_chapters_journals__page_numbers }}). {{ ac_profiles.books_book_chapters_music__publisher_name_and_place }}<br>"}, {'type': 'Creative Production or Composition', 'heading': 'Creative Productions or Compositions', 'info': "{{ ac_profiles.name_of_author_s_ }} ({{ ac_profiles.year_published }}). <em>{{ ac_profiles.publication_title }}</em>. {{ ac_profiles.books_book_chapters_music__publisher_name_and_place }} {{ ac_profiles.conference_creative_performance__location }}<br>"}, {'type': 'Journal article', 'heading': 'Journal Articles', 'info': "{{ ac_profiles.name_of_author_s_ }} ({{ ac_profiles.year_published }}). <em>{{ ac_profiles.publication_title }}</em>. {{ ac_profiles.books_book_chapters_music__publisher_name_and_place }} {{ ac_profiles.journal__name }} {{ ac_profiles.journal__volume_and_issue }}<br>"} ] %}
{% for publication_type in publication_types %}
{% set associated_objects = crm_associations(dynamic_page_crm_object.id, "USER_DEFINED", 209, "research_or_scholarship_publication_=Research Publication&type_of_publication=" ~ publication_type.type ~ "&visible_publication=true&orderBy=-year_published", "publication_title, year_published, books_book_chapters_music__publisher_name_and_place, name_of_author_s_, book_chapter__book_name, book_chapters_journals__page_numbers, conference_creative_performance__name_of, conference_creative_performance__location, publication_external_link, journal__name, journal__volume_and_issue") %}
<h6>{{ publication_type.heading }}</h6>
{% for ac_profiles in associated_objects.results %}
{{ publication_type.info }}
{% endfor %}
<br>
{% endfor %}
</div>
</details>
{% endif %}
I’m using the above code to produce listings of academic publications on the site I’m creating. Here’s an example: https://8830131.hs-sites.com/people/publications/jeffrey-aernie?hsLang=en.
I’d like to only display publication headings if the academic has produced any of that type and also if only some of the fields are filled in (e.g. if page number may or may not be applicable) then if field is blank I want to not display this part of the string and move on.
Because the code is so tightly compacted, is there a way to achieve this with the existing way the code is? Can someone please recommend a way forward?
Thanks in advance ![]()