2

I have a list of items. Each item has a season. I am trying to organize the items by season. I believe the list is pre sorted and I need to create a header everytime there item has a new season

In php I would imagine something like this

$nextSeason = "";
foreach($list as $item){
    $season = $item->season;
    if($nextSeason != $season){
        $nextSeason = $season;
        echo '<h1>' . $season . '</h1>'
    }
}

I have no clue how to accomplish this within the EE templating language

Here is the current code looping through the list:

{exp:stash:get_list:1 name="classes"
    against="class_category_ids"
    match="#(^|\&|\s){category_id}(.|$)#"
    prefix="classes"
}

    <div class="col-sm-3 class-info-container">
      {classes:class_card}
    </div>
{/exp:stash:get_list:1}

If i add {classes:season} it is printing out the season for every item.

I also do not understand what the :1 is at the end of {exp:stash:get_list:1} I have looked at the documentation for stash but it does not have a reference for this.

I believe this site is running EE 2

0

Tough to tell without the whole setting/getting picture, but definitely possible to recreate the effect of your php example with Stash. See: https://gist.github.com/croxton/6219973 for an example of setting and getting headers and also the individual items for each header. It should apply to what you're trying to do. Also: https://github.com/croxton/Stash/wiki/Lists#three-and-more-dimensional-lists

The ending ":1" in the module tag is probably used because that stash get_list is within another stash tag pair. You can use any word (like "nested1", "nest2", "bubba" etc...) to differentiate each nested stash tag pair. I believe it's necessary due to the way eecms process module tags, but can't remember for sure.

1
  • Thanks, I will try to go through that example and make it work for my needs. I have tried using stash:get/set but it was not working very well. the get_list already has a match on it, can I use multiple matches? A match is needed to implement the example gist May 17 '17 at 17:24

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.