No, it's actually not as convoluted as it sounds... ;)
Got two channels: News, and News Commentary. News entries are published multiple times per day; News Commentary is published once a week and covers 5-10 News entries from that week.
News has a news__body
field, a news__images
Matrix of images (containing the usual suspect columns of file
, caption
, etc), and a news__credits
Matrix field with some plain text columns. It uses image shortcodes (those {image_1}
/ {image_2}
things) in the news__body
field to insert images from the news__images
field.
News Commentary basically just has a commentary__content
Matrix field, which has a related-news-article
Playa column linking each row to a News entry, as well as a commentary
textarea for the commentary portion.
The single-entry page for News Commentary displays a list (the commentary__content
matrix). Each list item should display the related News entry's news__body
and news__credits
fields (with images in position), with the commentary following.
I've got much of it working, but seem unable to get output from the News Commentary -> related News entry -> news__images
or news__credits
field. I get the news__body
content with {image_1}
shortcodes showing in the text, followed by the commentary
content - no news__credits
or replaced image shortcodes.
Following is my (simplified) template. It contains both the {exp:stash:set_list}
and {exp:stash:get_list}
loops.
Stash set_list:
{exp:stash:set_list name="news-commentary" parse_tags="yes"}
{exp:channel:entries channel="news-commentary" require_entry="yes"}
{stash:commentary__title}{title}{/stash:commentary__title}
{stash:news-commentary__entry_id}{entry_id}{/stash:news-commentary__entry_id}
{exp:stash:set_list:commentary__content name="commentary__content" context="entry_{entry_id}" parse_tags="yes"}
{commentary__content} {!-- Matrix --}
{stash:row_count}{row_count}{/stash:row_count}
{related-news-article var_prefix="related_article"} {!-- Playa --}
{stash:news__title}{related_article:title}{/stash:news__title}
{stash:news__entry_id}{related_article:entry_id}{/stash:news__entry_id}
{related_article:news__images var_prefix="image_matrix"} {!-- Matrix --}
{exp:stash:set name="image_{image_matrix:row_count}" type="snippet"}
<img src="{image_matrix:file}">
{/exp:stash:set}
{/related_article:news__images} {!-- END Matrix --}
{!-- Parse to replace image shortcodes with images - theoretically --}
{exp:stash:parse parse_vars="yes" process="end"}
{stash:news__body}{related_article:news__body}{/stash:news__body}
{/exp:stash:parse}
{exp:stash:set_list:news__credits name="news__credits" context="entry_{entry_id}" parse_tags="yes"}
{related_article:news-credits var_prefix="credits_matrix"}
{stash:credits__text}{credits_matrix:text}{/stash:credits__text}
{stash:credits__url}{credits_matrix:url}{/stash:credits__url}
{/related_article:news-credits}
{/exp:stash:set_list:credits}
{/related-news-article} {!-- END Playa --}
{stash:commentary}{commentary}{/stash:commentary}
{/commentary__content} {!-- END Matrix --}
{/exp:stash:set_list:commentary__content}
{/exp:channel:entries}
{/exp:stash:set_list}
Stash get_list:
{exp:stash:get_list name="news-commentary"}
<h1>{commentary__title}</h1>
<ol class="commentary-list">
{exp:stash:get_list:commentary__content name="commentary__content" context="entry_{news-commentary__entry_id}"}
<li>
<h2>{news__title}</h2>
{news__body}
{exp:stash:get_list:news__credits name="news__credits" context="entry_{news__entry_id}"}
{stash:credits__text}
{stash:credits__url}
{/exp:stash:set_list:credits}
{if commentary}
<h3>Commentary</h3>
{commentary}
{/if}
</li>
{/exp:stash:get_list:commentary__content}
</ol>
{/exp:stash:get_list}
FYI, due to massive simplification and obfuscation of the actual template code, any typos you find may or may not be actual problems in the original template. ;)