1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » Selecting Particular Posts [SOLVED]
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 320 Views |
-
Selecting Particular Posts [SOLVED]

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;
} -
Re: Selecting Particular Posts [SOLVED]

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.
| 320 Views | ||
|
Page:
1
|
Go to Top |


