<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Forum posts to 'Site Builders'</title>
		<link>http://www.silverstripe.com/site-builders-forum/</link>
		

		
		<item>
			<title>Re: Displaying first 5 news items from multiple years</title>
			<link>http://www.silverstripe.com/site-builders-forum/show/71257?showPost=72118</link>
			<description>Looking at that code, it would seem to pull 5 news items from each year, rather than 5 in total. I have attacked it from a different point, creating a new page type called NewsPage, which is just a duplicate of ArticlePage. Now I can pull the most recent media releases, where ever they are, using:&lt;br /&gt;function LimitedNews($limit) {&lt;br /&gt;$littlechildren = DataObject::get(&quot;NewsPage&quot;, &quot;&quot;,  &quot;Date DESC&quot;, null, $limit);&lt;br /&gt;return $littlechildren;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;cheers&lt;br /&gt;bruce&lt;br&gt;&lt;br&gt;Posted to: Displaying first 5 news items from multiple years</description>
			<pubDate>Thu, 15 May 2008 12:17:01 +1200</pubDate>
			<author>Bruce Bowden</author>
			<guid>http://www.silverstripe.com/site-builders-forum/show/71257?showPost=72118</guid>
		</item>
		
		<item>
			<title>Re: Displaying first 5 news items from multiple years</title>
			<link>http://www.silverstripe.com/site-builders-forum/show/71257?showPost=71328</link>
			<description>So you have 1 article holder for each year?? Then you can get a DataObjectSet of every ArticleHolder then query on each to return the children - or pages with that parent ID as we need to limit it to 5. Remember this is cut down to make it easier to read. I would add an if round the foreach to prevent any errors and you might want to get the ArticleHolders in some order.&lt;br /&gt;&lt;br /&gt;$output = new DataObjectSet();&lt;br /&gt;$years = DataObject::get(&quot;ArticleHolder&quot;);&lt;br /&gt;foreach($years as $year) {&lt;br /&gt;$articles = DataObject::get(&quot;ArticlePage&quot;,&quot;ParentID = $year-&amp;gt;ID&quot;,&quot;&quot;,&quot;&quot;, 5);&lt;br /&gt;$output-&amp;gt;push($articles);&lt;br /&gt;}&lt;br /&gt;return $output;&lt;br&gt;&lt;br&gt;Posted to: Displaying first 5 news items from multiple years</description>
			<pubDate>Wed, 14 May 2008 23:36:20 +1200</pubDate>
			<author>Will Rossiter</author>
			<guid>http://www.silverstripe.com/site-builders-forum/show/71257?showPost=71328</guid>
		</item>
		
		<item>
			<title>Displaying first 5 news items from multiple years</title>
			<link>http://www.silverstripe.com/site-builders-forum/show/71257</link>
			<description>The Tutorial has an example that shows the last 5 news items on the front page. However I have grouped my media releases under ArticleHolder pages by year so I can't just use  &quot;ParentID = $this-&amp;gt;ID&quot; as the filter in the DataObject::get.&lt;br /&gt;&lt;br /&gt;I need to say: &quot;Find all the ArticlePages that have the 'Media releases' page at Level(2)&quot;. &lt;br /&gt;&lt;br /&gt;Does someone have the appropriate syntax for that? Or do I need to provide more context?&lt;br /&gt;&lt;br /&gt;cheers&lt;br /&gt;bruce&lt;br&gt;&lt;br&gt;Posted to: Displaying first 5 news items from multiple years</description>
			<pubDate>Wed, 14 May 2008 19:42:42 +1200</pubDate>
			<author>Bruce Bowden</author>
			<guid>http://www.silverstripe.com/site-builders-forum/show/71257</guid>
		</item>
		

	</channel>
</rss>
