Have you created code you'd like to share with the dotCMS community?
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 org.apache.velocity.tools.generic.SortTool@2d0fb58e 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 org.apache.velocity.tools.generic.SortTool@2d0fb58e: https://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/SortTool.html
## First, set your lists #set($newsList = $dotcontent.pull("+structureName:CcNewsStories ...")) #set($sparkList = $dotcontent.pull("+structureName:CcSparkContents ... ")) #set($vergeList = $dotcontent.pull("+structureName:CcVergeFeatureStory ...")) ## Now combine them into one list #set($combined = ) #foreach($n in $newsList) #set($test = $combined.add($n)) #end #foreach($s in $sparkList) #set($test = $combined.add($s)) #end #foreach($v in $vergeList) #set($test = $combined.add($v)) #end #if($combined.size() > 0) <ul> ## Here's the key: use the $sorter tool on your foreach statement #foreach($c in $sorter.sort($combined,"publishDate:desc")) <li> <!--Display your story --> </li> #end </ul> #end