Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Get entries of a specific blogHolder in SS3


Go to End


3 Posts   1597 Views

Avatar
sajok

Community Member, 82 Posts

12 April 2013 at 12:47pm

Edited: 12/04/2013 12:50pm

Hello,

I'm trying to get the latest blog entries from a specific blogholder, to be shown inside another blogholder using this code:

class BlogHolderDecorator extends DataExtension { 
   
   public function latestNews($max) {
   		$holder = DataList::create('BlogHolder')->filter('URLSegment', 'blog');
         return DataList::create('BlogEntry')->filter('ParentID', $holderID)->limit($max);
	} 
}

in BlogHolder.ss I have:

<% loop latestNews('5') %>
	<li>
	<h4>$Title</h4>
	<p>$Content.FirstParagraph(html)</p>
	</li>
<% end_loop%>

This doesn't work yet.. any idea what I'm missing here?

Thanks

Avatar
Willr

Forum Moderator, 5523 Posts

12 April 2013 at 8:25pm

Your PHP has a few little typo's. It should look like

$holder = DataList::create('BlogHolder')->filter('URLSegment', 'blog')->first();

return DataList::create('BlogEntry')->filter('ParentID', $holder->ID)->limit($max);

Avatar
sajok

Community Member, 82 Posts

13 April 2013 at 12:54am

Thank you Willr, it works now.