1

I have a page where i want to output some quotes from certain channel within an other entries tag.

It seems to work sofar but stash is outputting the same entry over again, i wanted to use get_list for the unique parameter.

Thanks for your time and effort

Here is my code:

     {exp:channel:entries channel="ffq" status="open"}
            {exp:stash:set_list name="quotes"} 
            {stash:quote}{textarea}{/stash:quote} 
            {/exp:stash:set_list}
        {/exp:channel:entries}


         {exp:channel:entries channel="story" orderby="random" category="4" status="open|featured"}
          {other ee stuff}

{if count % 2 == 0}
               {exp:stash:get_list name="quotes" unique="yes"}
                    {quote}
               {/exp:stash:get_list}
{/if}
     {/exp:channel:entries}
1

I believe it's outputting the same thing over and over as you've only captured the last 'quote' – you are capturing inside the {exp:channel…} tag. So every time EE returns another entry, you are overwriting the last entry. Try instead:

{exp:stash:set_list name="quotes" trim="yes' parse_tags="yes"} 
    {exp:channel:entries channel="ffq" status="open"}
        {stash:quote}{textarea}{/stash:quote} 
    {/exp:channel:entries}
{/exp:stash:set_list}

This should at least give you multiple quotes.

As for {exp:stash:get_list} what you have currently will output all unique quotes and not just unique quotes every 2 iterations. To achieve that will require some thought as you'd likely have use a combination of offset, limit & slice.


UPDATE

{exp:channel:entries channel="story" orderby="random" category="4" status="open|featured"}
{other ee stuff}

{if count % 2 == 0}
    {exp:stash:get_list 
        name="quotes"
        limit="2" //Limit to 2 Quotes
        offset="{count}" //Your outer count will be 2/4/6/8/etc so we offset the get_list by the same amount.
    }
        {quote}
    {/exp:stash:get_list}
{/if}

{/exp:channel:entries}

Obviously you'll encounter issues if you only on want one quote every 2 outer loops as we're using the outer count but them's the breaks !

2
  • Thanks, that did help a lot. I am able to output all quotes now, when using the parameter orderby="random" i now have unique quotes most of the time but sometimes duplicate ones for there are still to {exp:stash:get_list}. Do you have any more ideas how two prevent duplicate quotes. I now have this sofar and can't quite comprehend the slice offset parameters for Stash yet. {exp:stash:get_list name="quotes" unique="yes" orderby="random"}
    – Dave_Daliz
    Mar 23 '16 at 13:28
  • Updated my original answer. Note: Your unique="yes" tag is only relevant to returning unique content within the list. Calling it every iteration does not look at what it out put last iteration. Mar 24 '16 at 0:38

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.