Jump to:

1835 Posts in 1139 Topics by 554 members

Blog Module

SilverStripe Forums » Blog Module » Selecting Particular Posts [SOLVED]

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 550 Views
  • shluckey
    Avatar
    Community Member
    19 Posts

    Selecting Particular Posts [SOLVED] Link to this post

    Hi,

    Using the blog module is it possible to stream particular posts to another page such as the second only or third post. The following code is for selecting the first posts depending on descending order, but I only want to choose say the second post. Is there any way to do this? any help is much appreciated.

    function LatestBlogPosts($num=2) {
    $news = DataObject::get_one("BlogHolder");
    return ($news) ? DataObject::get("BlogEntry", "ParentID = $news->ID", "Date DESC", "", $num) : false;
    }

  • IOTI
    Avatar
    Community Member
    187 Posts

    Re: Selecting Particular Posts [SOLVED] Link to this post

    Hi Shluckey,

    If you're still looking for an answer to this you could use the following to get 2nd post.

    function LatestBlogPosts() {
    $news = DataObject::get_one("BlogHolder");
    return ($news) ? DataObject::get("BlogEntry", "ParentID = $news->ID", "Date DESC", "", "2,1") : false;
    }

    Using "2,1" in the limit clause tells MySQL to return one record at the second position. So to get the third item you would use "3,1".

    Hope this helps.

  • shluckey
    Avatar
    Community Member
    19 Posts

    Re: Selecting Particular Posts [SOLVED] Link to this post

    Thanking you so much!

    550 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.