0

I'm using Stash for image replacement in my main column. {images} is a Matrix field.

In my body field, {image-1}, {image-2}, etc. are the image placeholders. My code looks like this ({images} is a Matrix field).

{images}
    {exp:stash:set name="image-{row_count}" type="snippet"}
        {exp:ce_img:single src="{image:url}"
     alt="{image:title}"}               
    {/exp:stash:set}
{/images}
{exp:stash:set name="content"}{body}{/exp:stash:set}
{exp:stash:get name="content" parse_vars="yes"}

This works fine, but then I need to run it again for the side column. I also run in to problems with my RSS feed - multiple entries on the page cause Stash to run over and over, but I'm not getting fresh results for each entry.

How do I make Stash run freshly each time?

2 Answers 2

1

Try this:

{exp:stash:content}
  {images}
    {exp:stash:set name="image-{row_count}" type="snippet"}
        {exp:ce_img:single src="{image:url}"
     alt="{image:title}"}               
    {/exp:stash:set}
  {/images}
  {exp:stash:parse}{body}{/exp:stash:parse}
{/exp:stash:content}

{exp:stash:get name="content"}
0

With what you already have set up: When you have multiple entries the stash 'image-{row_count}' variable can be overwritten each entry loop. Try adding in a reference to the entry id to distinguish the variables, like:

{images}
    {exp:stash:set name="image-{entry_id}-{row_count}" type="snippet"}
...
1
  • That won't work because {image-1}, {image-2}, etc. are the placeholders that get replaced with images. If they have the entry_id in them, they won't match up.
    – 4midori
    Jan 7, 2015 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.