I'm trying to use Stash embeds on a pretty complex site and can 'see' a way to make things more DRY but can't actually figure out how to 'do'.
I have a collection of viewModal templates, that handle the various channels, and a lot of these channels share a naming convention for their right column meta data. In a perfect world, I would've shared these fieldgroups across the channels, but as that's not possible, I had to repeat myself a lot in the fields.
An example (stripped down slightly):
/editorial.html (viewModal template)
{!-- Set the page layout --}
{stash:embed:layouts:standard}
{!-- Right side area [inject the rightcol_meta partial into the {stash:page_meta} region] --}
{exp:stash:set_value name="st_page_meta" value="{exp:stash:embed:partials:rightcol_meta}"}
{!-- Main content area --}
{exp:channel:entries limit="1" channel="editorial|structure_editorial" disable="member_data|pagination|categories" require_entry="yes"}
{exp:stash:st_page_title}{title}{/exp:stash:st_page_title}
{exp:stash:st_page_body}{cf_editorial_body}{/exp:stash:st_page_body}
{!-- (make all the meta fields snippets) --}
{!-- Related links --}
{exp:stash:set_list name="st_rel_links" parse_tags="yes"}
**{cf_editorial_rel_links}**
{stash:st_rel_link_title}{title}{/stash:st_rel_link_title}
{stash:st_rel_link_url}{page_url}{/stash:st_rel_link_url}
**{/cf_editorial_rel_links}**
{/exp:stash:set_list}
{!-- Related publications --}
{exp:stash:set_list name="st_rel_pubs" parse_tags="yes"}
**{cf_editorial_rel_publication}**
{stash:st_rel_link_title}{title}{/stash:st_rel_link_title}
{stash:st_rel_link_url}{page_url}{/stash:st_rel_link_url}
**{/cf_editorial_rel_publication}**
{/exp:stash:set_list}
{!-- featureboxes (make all the meta fields snippets --}
{exp:stash:set_list name="st_fbox_list" parse_tags="yes"}
**{cf_editorial_fbox}**
{stash:st_fbox_type}{cf_fbox_type}{/stash:st_fbox_type}
{!-- Heading style --}
{stash:st_fbox_heading}{cf_fbox_heading}{/stash:st_fbox_heading}
{stash:st_fbox_heading_body}{cf_fbox_body}{/stash:st_fbox_heading_body}
{!-- Image --}
{cf_fbox_img}
{stash:st_fbox_img_src}{url}{/stash:st_fbox_img_src}
{stash:st_fbox_img_alt}{alt_text}{/stash:st_fbox_img_alt}
{/cf_fbox_img}
{stash:st_fbox_img_link}{cf_fbox_img_link}{/stash:st_fbox_img_link}
**{/cf_editorial_fbox}**
{/exp:stash:set_list}
{/exp:channel:entries}
I've surrounded the parts I'm talking about in *s (turns out I can't bold inside a code snippet). I want to be able to change these sections into snippets, and instead of {cf_editorial_rel_links}
etc I would like to use {cf_{channel_short_name}_rel_links}
so that in each viewModal I could just include 1 snippet. Even if I had to use {cf_{exp:stash:get name="channel_name"}_rel_links}
it would be fine.
Is this possible? I think it is, but can't seem to get it to parse the channel short name (with stash or otherwise) in time for it to be processed correctly.
Thanks in advance for any help!
Rob