I have multiple channels with different field groups, but several duplicate fields. For example:
Channels:
- products_bikes
- products_skateboards
- products_trikes
Fields:
- bikes_summary
- skateboards_summary
- trikes_summary
I use the same detail template to output info for all of the channels, but with the duplicate fields, I have to repeat the "summary" field 3 times:
{exp:channel:entries
channel='products_bikes|products_skateboards|products_trikes'
}
<h1>{title}</h1>
{bikes_summary}
{skateboards_summary}
{trikes_summary}
{/exp:channel:entries}
And this isn't the only field that's repeated. So that can get pretty hairy, especially if I need to check if a field is empty or not, or if I want to add another product type in the future.
So ideally I'd be able to set a channel prefix, and use it in a single field tag:
{{channel_prefix}_summary}
I can't use the channel_short_name
because it doesn't match up, so I figured Stash might be able to do it. I tried:
{exp:stash:channel_prefix}
{if channel_short_name == 'products_bikes'}
bikes
{/if}
{if channel_short_name == 'products_skateboards'}
skateboards
{/if}
{if channel_short_name == 'products_trikes'}
trikes
{/if}
{/exp:stash:channel_prefix}
{{exp:stash:channel_prefix}_summary}
But that output the text "{bikes_summary}" rather than parsed the field tag. I figure parse order has to do with it, but I'm not sure how to fix it - or if it's possible.
Thanks for any help!