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 :P
Any help would really make my day thanks heaps
Nick
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
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 :P
Any help would really make my day thanks heaps
Nick
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).
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