0

Based on the documentation for stash list, there are 2 ways to specify lists.

One is to use {exp:stash:append_list} or {exp:stash:prepend_list}.

The other is to use {exp:stash:set_list}.

I am using #1 because I need to list the items in reverse order.

{exp:low_replace find="\r|\n|\t" replace="" regex="yes"}
    {exp:messages:foo
        limit="10"
        paginate="bottom"
        sort="desc"
    }
        {exp:stash:prepend name="test"}
            {stash:message}<section>{message}</section>{/stash:message}
        {/exp:stash:prepend}
    {/exp:messages:foo}

    {exp:stash:get_list name="test"}
        {message}
    {/exp:stash:get_list}
{/exp:low_replace}

The above doesn't work. Is it because I am using wrong tag to retrieve the list? Is prepend working at all?

UPDATE:

Apparently, I need to use {exp:stash:prepend_list} so I amended the code and tested it.

{exp:low_replace find="\r|\n|\t" replace="" regex="yes"}
    {exp:messages:foo
        limit="10"
        paginate="bottom"
        sort="desc"
    }
        {exp:stash:prepend_list name="test"}
            {stash:message}<section>{message}</section>{/stash:message}
        {/exp:stash:prepend_list}
    {/exp:messages:foo}

    {exp:stash:get_list name="test"}
        {message}
    {/exp:stash:get_list}
{/exp:low_replace}

Still, I get no results.

3

Your original code can't work because of parse order. Tag pairs are not parsed procedurally as you assume.

Module tags are parsed from the outer layer inwards - like peeling an onion. Plugin tags (the low_replace tag in this instance) are parsed in the opposite direction (unless parse="inward").

In your code therefore the get_list (layer 2) occurs before you have captured the list (layer 3).

You can solve this in several ways.

Set the list on the same parse layer as where you get it, using stash's ability to parse the tags it contains:

{exp:low_replace find="\r|\n|\t" replace="" regex="yes"}
    {exp:stash:set_list name="test" parse_tags="yes"}
        {exp:messages:foo
            limit="10"
            paginate="bottom"
            sort="desc"
        }
            {stash:message}<section>{message}</section>{/stash:message}
        {/exp:messages:foo}
    {/exp:stash:set_list}

    {exp:stash:get_list name="test"}
        {message}
    {/exp:stash:get_list}
{/exp:low_replace}

Or move the get_list to the end of template parsing. You'll need to get Stash to parse the low_replace tag too since EE has finished tag parsing by that point.

{exp:messages:foo
    limit="10"
    paginate="bottom"
    sort="desc"
}
    {exp:stash:prepend_list name="test"}
        {stash:message}<section>{message}</section>{/stash:message}
    {/exp:stash:prepend_list}
{/exp:messages:foo}

{exp:stash:get_list name="test" process="end" parse_tags="yes"}
    {exp:low_replace find="\r|\n|\t" replace="" regex="yes"}
            {message}
    {/exp:low_replace}
{/exp:stash:get_list}
  • It that first solution that you propose, does it output it in reverse order? The reason I was using {exp:stash:prepend_list} is that I didn't see anything I can do to {exp:stash:get_list} to reverse it's contents. – arvinsim Aug 20 '13 at 7:41
  • Also, in the first solution, does everything inside the {exp:stash:set_list} not get outputted? – arvinsim Aug 20 '13 at 8:41
  • Use the sort="desc" to reverse the order when you get_list. No, the content wrapped by set_list will not get output to the screen. – Mark Croxton Aug 20 '13 at 14:02
  • Did I workaround on that issue of the contents. Thanks! – arvinsim Aug 21 '13 at 0:50
0

I think your code has the wrong Stash tag--it's using "prepend," but needs "prepend_list:

{exp:stash:prepend_list name="test"}
    {stash:message}<section>{message}</section>{/stash:message}
{/exp:stash:prepend_list}

Does that fix it?

Updated:

Try this (moving the stash tag outside of your messages tag), instead:

{exp:stash:prepend_list name="test"}
   {exp:messages:foo
      limit="10"
      paginate="bottom"
      sort="desc"
    }
        {stash:message}<section>{message}</section>{/stash:message}
    {/exp:messages:foo}
{/exp:stash:prepend_list}
  • Amended the code and tested it. It still doesn't work. – arvinsim Aug 19 '13 at 2:14
  • Also, try testing it without the low_replace tag. If that works, then try using low_replace only around the {exp:stash:get_list...} or only around the {exp:messages:foo...} block--but NOT around both. – Jay F Aug 19 '13 at 3:00
  • Removed the low_replace tag...still didn't work. – arvinsim Aug 19 '13 at 3:28
0

Mark croxton has responded to your issue. He's the author of stash. Read his post. Read the documentation for stash. Your issue is parse order.

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.