Skip to main content
3 of 4
added 16 characters in body

Strange Stash Problem When Embedding

My Stash template has the following:

{if "{member_images:total_rows}" == 0}
    {!-- No images uploaded. Display placeholder as avatar. --}
    <img class="img-polaroid" src="http://placehold.it/133x100/" alt="No image uploaded"/>
{/if}
{if "{member_images:total_rows}" == 1}
    {!-- Only one image uploaded. Display that image as avatar. --}
    {member_images}
        <img class="img-polaroid" src="{member_image:133x100}" alt="{caption}"/>
    {/member_images}
{/if}
{if "{member_images:total_rows}" > 1}
    {if "{member_images:total_rows search:default="y"}" == 0}
        {!-- Multiple images upload, but none defined as default. Display first image as avatar. --}
        {member_images limit="1"}
            <img class="img-polaroid" src="{member_image:133x100}" alt="{caption}"/>
        {/member_images}                            
    {/if}                           
    {if "{member_images:total_rows search:default="y"}" == 1}
        {!-- Multiple images upload, and one defined as default. Display that image as avatar. --}                              
        {member_images search:default="y"}
            <img class="img-polaroid" src="{member_image:133x100}" alt="{caption}"/>
        {/member_images}                            
    {/if}
{/if}

This works fine. However, since I need this in different parts of my site, I figured I'd pull it out into its own stash template and just try to embed it where ever it's needed, like this:

{stash:embed name="common:.avatar" process="start"}

The problem is when I do this, nothing is outputted. When I enabled template debugging, I see the following error:

Parse error: syntax error, unexpected T_STRING in /home/devserver/public_html/system/expressionengine/libraries/Functions.php(683) : eval()'d code on line 12

I have no problems embedding other stash templates. Any ideas what might be wrong?

UPDATE 1:

The culprit seems to be the nested if block, particularly the if-conditions (e.g. {if "{member_images:total_rows search:default="y"}" == 0}. The if-condition contains a tag that must first be parsed? I'm guessing this might have something to do with parsing order, etc.?