I’m having a problem when I turn on caching for an embedded template. The scenario:
I use the Tag module to tag my gallery entries and automatically pull in gallery entries that share the same tag with whatever weblog entry is currently displayed. Pretty basic, and this is working fine.
In several places on my site, I want to display only the most recent gallery entry with a certain tag. So I’d made a template that does just that, and can then be embedded into all the places where I need to use this:
static/scanindex:
{exp:tag:gallery_entries tag="{embed:cattag}" gallery="scans" orderby="date" sort="desc" limit="1"}{entries}
{row}{exp:imgsizer:size src="{image_url}" width="110"}{sized}{/exp:imgsizer:size}{/row}
{/entries}{/exp:tag:gallery_entries}I then call it from my regular templates like this:
{exp:weblog:entries weblog="scans" orderby="title" sort="asc"}
{assign_variable:index_cat="{exp:tag:tags entry_id='{entry_id}' type='weblog' limit='1'}{tag}{/exp:tag:tags}"}
{embed="static/scanindex" cattag="{index_cat}"}
<a href="http://{url_title_path=scans/view}">{title}</a>{/exp:weblog:entries}This works fine if there’s just one entry on a page. However, if there are multiple weblog entries on the same page, and this embedded template gets called once for each entry, it displays the exact same thing for each entry - the data of the first one. Here are two screenshots for an example of it happening on my site (I’m probably not explaining it well so a visual might help):
Caching OFF (this is how it’s meant to look)
What it looks like once I turn caching ON
However, turning caching off significantly increases the load on my server as I use this embedded template all over the place.
What I’d hoped for, is that EE would automatically detect that each time the template is being called with a different embedded variable, and therefore make different caches for each (a little like how it makes different caches for the same page if there are different URL segments present).
Anyone have any ideas how can I solve this? Is it an error or bug, am I doing something wrong or could I be setting this up in a different way? I can’t really leave caching off - but I can’t seem to figure out a way around my problem!
Oh - and another reason for making this an embed: the code doesn’t work if I insert it into the template directly (conflicting variables, I think) - it only works from the embed. So, I can’t get rid of the embedded template completely. :/