I'm using a single template to display entries from several structures. Each structure has a cooresponding global field that is an entries field. I use this to display related entries as a sidebar. These fields are named sidebars.[structure handle]Sidebar, so fore example my blog sidebar global field would be sidebar.blogSidebar.
Coding the sidebar manually works fine, like this:
{% for block in sidebars.blogSidebar %}
...
{% endfor %}
But I'm trying to dynamically set the related entries field, and it isn't working:
{% set sidebar = "sidebars." ~ entry.section.handle ~"Sidebar" %}
{% for block in sidebar %}
...
{% endfor %}
This code doesn't output anything. If i just output {{ sidebar }}, it shows what I expect, ex: sidebars.blogSidebar.
And if I manually add it to the for loop {% for block in sidebars.blogSidebar %}, it works as expected.
Is there a different way to concatenate the name to make this work?