2

I have a getResources call, the result looks more or less like this:

  • 01.01.2016 - new year's lunch (meetings)
  • 11.12.2015 - writing class (classes)
  • 01.12.2015 - trip to London (trips)
  • 23.11.2015 - french class (classes)

I can sort them by tags:

  • classes
  • meetings
  • trips

It works very well. This is my code:

[[!getResourcesTag?
             &parents=2`  
             &tagKey=`Tags` 
             &showHidden=`1`
             &tpl=`datesTpl
             &limit=`3`
             &includeContent=`1`
             &includeTVs=`1`
             &processTVs=`1`
             &tvPrefix=`` 
             &hideContainers=`1`
             &pageLimit=`10` 
         ]]

Now comes the part, that makes problems to me. I want to group the result by month. So the result I would like to achieve is:

January 2016

01.01.2016 - new year's lunch (meetings)

December 2015

  • 11.12.2015 - writing class (classes)
  • 01.12.2015 - trip to London (trips)

November 2015

  • 23.11.2015 - french class (classes)

The TV, that outputs the date has the name "date". This TV gives me for every entry a timestamp output. For example: "2015-12-11 00:56:00". I wrote a snippet (formatDate), that outputs me later the format I wish. I use it like this:

[[formatDate? &date=`[[+date]]`]]

So I thought I could use Archivist Grouper for that issue. But it is not working. Somehow it doesn't process my TVs. Here is my code: 1

[[!ArchivistGrouper? &parents=`2` &itemTpl=`datesTpl` &includeTVs=`1` &tvPrefix=`` &includeContent=`1` &processTVs=`1`]]

My result with Archivist Grouper is:

January 2016

  • 01.01.2016 - new year's lunch ()

December 2015

  • 01.01.2016 - writing class ()
  • 01.01.2016 - trip to London ()

November 2015

  • 01.01.2016 - french class ()

So my question is, can I get the result I wish also with getResources? Or do you have any idea to get it run! I hope very much you can help. I am happy for every hint smiley

peace_love
  • 6,229
  • 11
  • 69
  • 157
  • I tested for example &tvFilters=`date==2015-12%` but it is not helping very much, because I need a automatic filter. And also it is not working anymore as soon as I am filtering by tags – peace_love Dec 28 '15 at 14:40

2 Answers2

0

you will not be able to set up getResources to output anything in a grouped format. You will have to write your own snippet.

You can turn on debugging in getResources to see what sort of query it is outputting and either copy that to your snippet [not so great] or rebuild it using xPDO [better], iterate through that to get your grouping and you would have to bone up on getChunk to format your output.

Sean Kimball
  • 4,506
  • 9
  • 42
  • 73
0

This will break it up by year.

[[pdoNeighbors?
    &id=`[[+id]]`
    &tplWrapper=`@INLINE [[+next]]`
    &sortby=`publishedon`
    &sortdir=`asc`
    &tplNext=`@INLINE [[+publishedon:strtotime:date=`%Y`]]`
    &toPlaceholder=`neighborYear`
]]
[[+neighborYear:notequalto=`[[+year]]`:then=`<h3>[[+neighborYear]]</h3>`]]
   <dt>[[+publishedon:strtotime:date=`%m/%d/%Y`]]</dt>
   <dd><a href="[[~[[+id]]]]" [[+link_attributes]] title="[[+pagetitle]]">[[+pagetitle]]</a></dd>
[[+publishedon:strtotime:date=`%Y`:toPlaceholder=`year`]]

To break it down further by year and month use %Y%m

Karchunk
  • 1
  • 1