1

Trying to build an archive with Stash & Low Yearly Archive, but not getting it to work as I need. The result that I get with the code below is:

 - 2013
 - 2012

Everything within the nested list is not getting set it seems. Can you help spot what I am missing?

Setting the list with:

      {exp:stash:set_list name="yearly-archive" parse_tags="yes" parse_depth="2"}
            {exp:low_yearly_archives channel="news" start_month="1" status="not closed" sort="desc" dynamic="off"}                  
                {stash:year}{year}{/stash:year}
                {stash:year_count}{year_count}{/stash:year_count}
                {stash:total_years}{total_years}{/stash:total_years}                    
                {exp:stash:set_list:nested name="news_months_{year}" parse_tags="yes"}
                    {months}
                        {stash:num_entries}{num_entries}{/stash:num_entries}
                        {stash:month}{month}{/stash:month}
                        {stash:month_short}{month_short}{/stash:month_short}
                        {stash:month_num}{month_num}{/stash:month_num}
                    {/months}
                {/exp:stash:set_list:nested}
            {/exp:low_yearly_archives}
        {/exp:stash:set_list}

Retrieving with:

 {exp:stash:get_list name="yearly-archive" parse_tags="yes"}
 {if year_count == '1'}<ul>{/if}
      <li>
      {year}
      <ul>  
      {exp:stash:get_list:nested name="news_months_{year}" parse_conditionals="yes" parse_tags="yes"}
           <li>
           {if num_entries != 0}
                <a href="{path=blog/archive}{year}/{month_num}/" title="{num_entries} entries in {month} {year}">{month_short}</a>
           {if:else}
                {month_short}
           {/if}
           </li>
      {/exp:stash:get_list:nested}
      </ul>
 </li>
 {if year_count == total_years}</ul>{/if}
 {/exp:stash:get_list}

When adding output="yes" to the set_list & set_list:nested tags the outer tag outputs as expected:

 year|=|2013|&|year_count|=|1|&|total_years|=|2|+|year|=|2012|&|year_count|=|2|&|total_years|=|2

The inner (nested tag) outputs nothing...

Thanks for taking a gander!

  • Have u tried just using the low archives tag to make sure your output is proper ? Basically leave stash out and it works ? – stuartmcd69 Mar 22 '13 at 3:12
  • Yes, I have it currently working without stash. Using Low's basic example. But me trying to be clean and consistant, I'd love to separate the viewmodel from the templates. – Dan Johnson Mar 22 '13 at 13:45
  • Have you tried setting output="yes" on the set_list tags? That's always handy for debugging as it lets you see what's being saved where. – Dom Stubbs Mar 22 '13 at 14:37
  • Output on the outer list outputs as expected. (I will attach on original post.) The nested tag outputs nothing. As I understand, the {months} tag pair is a loop right? – Dan Johnson Mar 22 '13 at 16:35
  • Looks like it should be, yep. How about if you disable/comment out the set_list tags? That'll give you an idea of whether the {months} loop is working. – Dom Stubbs Mar 22 '13 at 18:16
1

It could be that the {months} variable pair tagdata is removed from the template and appended to the output later on.

Please could you try this: instead of wrapping the inner {exp:stash:set_list} around the tag pair, use {exp:stash:append_list} inside the tag pair. Also, when you get the list, don't use parse_tags="yes" on either of the get_list tags - no further parsing is required at that point.

| improve this answer | |

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.