0

Using getResources, i want to get the latest resource created per container, so here's the resource tree structure:

-Parent
  --Container 1
     ---Resource 1
     ---Resource 2
     ---Latest Resource
  --Container 2
     ---Resource 1
     ---Latest Resource
  --Container 3
     ---Resource 1
     ---Resource 2
     ---Latest Resource

By using [[getResources]] how can i possibly be able to get only the resources Latest Resource?

PHP Noob
  • 1,597
  • 3
  • 24
  • 34
  • 1
    Not exactly sure what you want listed, is it something like: - Container 1 Latest Resource - Container 2 Latest Resource - Container 3 Latest Resource ? How is "Latest Resource" determined... by the most recent to be added, published, updated, etc? – okyanet Jun 07 '13 at 04:00
  • Can you just use a getResource per container? Or are they dynamically created containers? You could then sort by the publish date of the resource, eg: &sortby=`{"publishedon":"ASC"}` – MeltingDog Jun 18 '13 at 22:39

2 Answers2

0
&parents=`1`&sortBy=`publishedOn`&sortdir=`DESC`&limit=`1`
&parents=`2`&sortBy=`publishedOn`&sortdir=`DESC`&limit=`1`
&parents=`3`&sortBy=`publishedOn`&sortdir=`DESC`&limit=`1`

You could also do a getPage with a custom Snippet grabbing the last modResource of the desired parents. The parents=... above will have to represent actual modResource IDs available in the Manager.

0

You can do a nested getResources-call.

Assuming that all Containters have the same template (e.g. "3"):

  1. getResources

    [[getResources? 
           &limit=`0`
           &depth=`1`
           &where=`{"template:=":3}`
           &includeContent=`0`
           &includeTVs=`0`
           &processTVs=`0`
           &tpl=`chunk1`
    ]]
    
  2. chunk1

    [[getResources?
            &parents=`[[+id]]`
            &sortby=`{"publishedon":"DESC"}`
            &hideContainers=`1`
            &limit=`1`
            &depth=`1`
            &includeContent=`1` 
            &includeTVs=`1` 
            &processTVs=`1`
            &tpl=`chunk2`
    ]]
    
  3. chunk2

    Here you put the placeholdes you want, e.g. [[+pagetitle]], [[+content]]

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
achterbahn
  • 50
  • 6