开发者

MODx - List resources, group by year and subgroup by month

I have a specific question about MODx and how to make a list that groups by publishedon Year and subgroups by publishedon Month. Something like this:

<ul>
 <li>2011
  <ul>
   <li>May
    <ul>
     <li><h2>News heading</h2><p>News content</p></li>
     <li><h2>News heading</h2><p>News content</p></li>
    </ul>
   </li>
   <li>April
    <ul>
     <li><h2>News heading</h2><p>News content</p></li>
     <li><h2>News heading</h2><p>News content</p></li>
    </ul>
   </li>
  </ul>
 <li>2010
  <ul>
   <li>May
    <ul>
     <li><h2>News heading</h2><p>News content</p></li>
     <li><h2>News heading</h2><p>News content</p></li>
    </ul>
   </li>
   <li>April
    &l开发者_运维技巧t;ul>
     <li><h2>News heading</h2><p>News content</p></li>
     <li><h2>News heading</h2><p>News content</p></li>
    </ul>
   </li>
  </ul>
</ul>

I looked at Archivist, but it doesn't seem to give me a lot of options.

Is it possible to use getResources or do I have to write my own snippet?

Thanks.


Since Archivist 1.2.0, you can use &groupByYear=`1` and &groupByYearTpl to allow for grouping results by year in Archivist, into nested lists.

Apparently, the doc doesn't mention about this, but this is the commit: https://github.com/splittingred/Archivist/commit/45d2cfe137a2f5904bb4b639b1c64a4eb680968b


This should be possible using getResources, as you should be able to nest getResources calls.

So basically you get your years in your outer getResources call and within the template for that call you include another getResources call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜