1

With multiple blog listing templates: index, category, tag, archive, search-results etc - the markup for those listings never really changes between templates.

However, if we need to add something to the li for example, we need to change each template. It would be much more efficient if that li was stored once and reusable throughout our blog templates.

Is that something Stash could do and more importantly would it work where we're using Low Search.

2 Answers 2

4

Couldn't you just use a Snippet for this? It would contain the markup and code used inside a tag, which you could re-use with multiple tags. For example:

{exp:low_search:results ... }
   {sn_entry_list}
{/exp:low_search:results}

{exp:channel:entries ... }
   {sn_entry_list}
{/exp:channel:entries}

An so on.

2
  • Wasn't sure if that would work with snippets parsing earlier? Also have conditionals inside to display icons depending on the category and also add 'tagged with x' where a post has tags (using Rumbelow's Taggable). Nov 22, 2013 at 11:27
  • 1
    The snippets aren't exactly parsed but their content is put in the template for processing. Having any conditionals or tags in there shouldn't be a problem at all.
    – Low
    Nov 22, 2013 at 11:34
1

Snippet would work, but personally I prefer a Stash approach since you can keep the list item markup in the same place as the data fetching logic. This is how I'm doing almost exactly the same thing, also using Low Search: https://gist.github.com/thisisjamessmith/6892683

2
  • honestly, if I had the time I'd probably have learned more about Stash (although not sure about how future proof Stash will be long-term after something I heard in Portland). But I needed a quick win here and the snippet did just the job, especially because we weren't always pulling the same number of entries and sometimes not showing pagination. Nov 22, 2013 at 13:53
  • Steven, what exactly did you hear? There's a lot of EE devs who are using Stash on practically every build. Nov 24, 2013 at 15:20

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.