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.

Blog Module /

Discuss the Blog Module.

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

Get entries of a specific blogHolder in SS3


Reply


3 Posts   758 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, 5513 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.