Combine multiple structure sources into the same content pull


We have multiple news outlets on campus that ended up being created in different structures. When we wanted to syndicate these news sources onto one page, we needed a way to present them in a co-mingled list listed newest first. But how could we do that with 3 different structures? The key to making this work is having the publication date field in each of the 3 structures named the same. I suppose there's a way around this but fortunately I didn't need to give that much thought. The other key is using the velocity tool on your foreach statement. This is what does the actual sort once you've got all your data in one list. More info on


${esc.h}${esc.h} First, set your lists

${esc.h}set(${esc.d}newsList = ${esc.d}dotcontent.pull("+structureName:CcNewsStories ..."))
${esc.h}set(${esc.d}sparkList = ${esc.d}dotcontent.pull("+structureName:CcSparkContents ... "))
${esc.h}set(${esc.d}vergeList = ${esc.d}dotcontent.pull("+structureName:CcVergeFeatureStory ..."))

${esc.h}${esc.h} Now combine them into one list
${esc.h}set(${esc.d}combined = [])
${esc.h}foreach(${esc.d}n in ${esc.d}newsList)
  ${esc.h}set(${esc.d}test = ${esc.d}combined.add(${esc.d}n))
${esc.h}foreach(${esc.d}s in ${esc.d}sparkList)
  ${esc.h}set(${esc.d}test = ${esc.d}combined.add(${esc.d}s))
${esc.h}foreach(${esc.d}v in ${esc.d}vergeList)
  ${esc.h}set(${esc.d}test = ${esc.d}combined.add(${esc.d}v))

${esc.h}if(${esc.d}combined.size() > 0)

    ${esc.h}${esc.h} Here's the key: use the ${esc.d}sorter tool on your foreach statement
    ${esc.h}foreach(${esc.d}c in ${esc.d}sorter.sort(${esc.d}combined,"publishDate:desc"))
         <!--Display your story -->