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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Blog Module /

Discuss the Blog Module.

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

Selecting Particular Posts [SOLVED]


Go to End


3 Posts   1678 Views

Avatar
shluckey

Community Member, 19 Posts

14 February 2013 at 3:01am

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

Avatar
copernican

Community Member, 189 Posts

13 March 2013 at 3:45am

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.

Avatar
shluckey

Community Member, 19 Posts

28 March 2013 at 2:52am

Thanking you so much!