1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » Can I offset a Latest posts Called on the home page
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 925 Views |
-
Can I offset a Latest posts Called on the home page

17 February 2011 at 6:57pm
Hi people i have pulled latest blog posts on my manin page but wondered if i could offset the <% control LatestNews(1) %> call so I could have the 2 post in an alternate layout
Im new be nice
Any help would really make my day thanks heaps
Nick
-
Re: Can I offset a Latest posts Called on the home page

18 February 2011 at 12:19pm
You can try having a 'limit' and an offset. ie
<% control LatestNews(1, 1) %>
Then in your function you would have
function LatestNews($num=5, $offset=0) {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", "{$offset,$num}") : false;
}I'm pretty sure passing 2 arguments to a function works. If not then you may need to get rid of the 'limit' one and use it for offset (since you aren't changing the limit).
-
Re: Can I offset a Latest posts Called on the home page

18 February 2011 at 1:50pm
Thanks for the help it exactly what i was looking for !!!
Silverstripe certainly turning out to be a great platform
i did however have to remove the {} as i was getting a syntax error but now seems to be working fine
function LatestNews($num=5, $offset=0) {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", "$offset,$num") : false;
}Thank you so much for you help and saving me a massive headache
Cheers
Nick
| 925 Views | ||
|
Page:
1
|
Go to Top |


