I'm building a multilingual site, which has a fallback to English if the article isn't available in the users selected language. I'm using freebie_1 to switch the custom field for each language.
I'm still fumbling my way round Stash and guessing the following code should work. However, on the front end I'm only seeing {cf_news_title_en}
How can I pass the {lang}
variable in to the custom field to render correctly?
{exp:channel:entries channel="news" dynamic="off"}
{if "{cf_news_title_{freebie_1}}" != ""}
{exp:stash:set_value name="lang" value="{freebie_1}"}
{/if}
{if "{cf_news_title_{freebie_1}}" == ""}
{exp:stash:set_value name="lang" value="en"}
{/if}
{exp:stash:append_list name="news"}
{stash:news_title}{cf_news_title_{lang}}{/stash:news_title}
{stash:news_page_url}{site_url}{freebie_1}/news/{url_title}{/stash:news_page_url}
{stash:news_intro}{cf_news_intro_{lang}}{/stash:news_intro}
{/exp:stash:append_list}
{/exp:channel:entries}
{exp:stash:get_list name="news" type="snippet"}
<article>
<header>
<h2><a href="{news_page_url}">{news_title}</a></h2>
</header>
{if news_intro != ""}<p class="lead">{news_intro}</p>{/if}
</article>
{/exp:stash:get_list}