1

So I have my content that I put on my template article.html via the EE-publishform where I also get to choose wether to use layouts 'normal' or ' wide'. The size of the images varies depending on wich layout I use. CE_image is what I use to resize images.

problem

What I cant figure out is how to let CE_image do its work on the layout-template instead of on the article-template. Or if I could put the CE_image-tags on the article-template and then let the layout-templates insert apropriate values to size, crop and quality variables.

disclaimer

I realize Stash is a genuinly complex and competent addon and the solution to my problem is probably right there in the Stash documentation. I have read it over and over and tried things over and over but I never seem to hit the keys in the right order. So I am very ready for some advice on this matter.

Thanks /David

content

  • title
  • body
  • images (matrix-field)
    • img-1
    • img-2
    • img-3

Templates

Article

{exp:channel:entries channel="archive" limit="1" url_title="{segment_2}"}

{embed="_layouts/{f-archive-layout}"}

{exp:stash:set name="title"} {title} {/exp:stash:set}

{exp:stash:set name="content"} {f-body} {/exp:stash:set}

{exp:stash:set name="images"} {f-archive-images} {exp:ce_img:pair src="{f-archive-images-image}" width="400" crop="yes" quality="80"} {/exp:ce_img:pair} {/f-archive-images} {/exp:stash:set}

{/exp:channel:entries}

Layouts

normal

normal template

wide

wide template

4

You'd be better off just 'stashing' the image urls and using the CE Image tag from within the layout.

Article

{f-archive-images}
  {exp:stash:set_list name="images"}
    {stash:url}{f-archive-images-image}{/stash:url}
  {/exp:stash:set_list}
{/f-archive-images}

Layout

First image:
{exp:stash:get_list name="images" limit="1"}
  {exp:ce_img:single src="{url}" width="400" crop="yes"}
{/exp:stash:get_list}

Second and third images:
{exp:stash:get_list name="images" offset="1" limit="2"}
  {exp:ce_img:single src="{url}" width="400" crop="yes"}
{/exp:stash:get_list}

The point is that you are trying to keep your presentation separate. The CE Image tag, to me, is a presentational tag. You just need to get the image url to the layout. The above is one way to do it.

You could also use three separate {exp:stash:set name="image_x"}{/exp:stash:set} tags. Whatever you find that works.

| improve this answer | |
  • Ah, it was the list-thingy! thanks a lot! – David S May 4 '13 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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