0

I have a couple of formats that a news story can display on the site. I have each of these as a different Stash embed.

They're named in this format: story-block, story-focal, story-standard.

The site is in a magazine format and so uses many different styles on one page, often mix and matching them.

For example, on the homepage it loads in 16 blog posts, the first 4 are in story-block format, the next 6 are in story-standard format and the final is in story-block format.

The following code doesn't work, but demonstrates the concept I'm trying to achieve.

  <div class="two-by">
    {exp:stash:get_list name="news" limit="4"}
      {exp:stash:embed:modules:story-block process="start"}
    {/exp:stash:get_list}
  </div>

  {exp:stash:get_list name="news" limit="6" offset="4"}
    {exp:stash:embed:modules:story-standard}
  {/exp:stash:get_list}

  {exp:stash:get_list name="news" limit="1" offset="10"}
    {exp:stash:embed:modules:story-block}
  {/exp:stash:get_list}

story-block has the following markup:-

<article class="story story--block">
  <a href="{url}">
    <img src="{photo}">
    <div class="story__details">
      <h2 class="main-title">{title}</h2>
      {excerpt}
      <div class="mini-meta">
        <span>{type}</span>
        <span>{date}</span>
      </div>
    </div>
  </a>
</article>

But when rendered it doesn't load in the data, it will still show {title}.

My inkling is that embedding with process="start" should do the trick as it would then work as an EE snippet would, but this doesn't make a difference.

If I don't embed and instead copy the code directly into the template it works fine - but this is going to lead to massive code duplication around the site.

Is this possible, or is there a workaround?

5
  • If I pass the listed values into the embed (ie {exp:stash:embed name="modules:story-block" stash:title="{title}"} it works, but I feel like that is an unnecessary step and there is probably a parameter to share the same vars as where it was called from (as a snippet would vs this embed-like method)
    – Mutual
    May 21, 2014 at 15:17
  • Try changing your stash embed code from {exp:stash:embed:.... to {stash:embed:... (remove the "exp"}? May 21, 2014 at 15:47
  • That did it, thanks Romans. Submit it as an answer and I'll approve it :-)
    – Mutual
    May 22, 2014 at 8:59
  • Why use a stash embed here at all? A snippet would work fine. May 28, 2014 at 13:23
  • Snippets would be loaded on each page. They're loaded early, and even snippets you don't need are loaded on page load. With Stash embeds you can make them work as if they're snippets without that overhead. But on this particular site I think you're right, snippets would be fine.
    – Mutual
    May 28, 2014 at 13:29

1 Answer 1

1

Change the stash embed from {exp:stash:embed:.... to {stash:embed:... (remove the "exp").

Your Answer

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

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