Jump to:

1851 Posts in 1606 Topics by 561 members

Blog Module

SilverStripe Forums » Blog Module » Get entries of a specific blogHolder in SS3

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 710 Views
  • sajok
    Avatar
    Community Member
    82 Posts

    Get entries of a specific blogHolder in SS3 Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Get entries of a specific blogHolder in SS3 Link to this post

    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);

  • sajok
    Avatar
    Community Member
    82 Posts

    Re: Get entries of a specific blogHolder in SS3 Link to this post

    Thank you Willr, it works now.

    710 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.