1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » Latest articles from multiple Blogs on Homepage required
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1332 Views |
-
Latest articles from multiple Blogs on Homepage required

16 August 2009 at 11:03am
Hi all
I'm trying to create a list of the latest blog articles from the many Blog Holders on my site. At present I only get the articles from one of the Blogs. Can anyone help please???My code so far is:
...Homepage.php......................................................
function LatestNews($num=5) {
$news = DataObject::get_one("BlogHolder");
return ($news) ? DataObject::get("BlogEntry", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}...Homepage.ss.........................................................
<ul id="NewsList">
<% control LatestNews %>
<h6 class="newsDateTitle"><a href="$Link" title="Read more on "{$Title}"">$Title</a></h6>
<ul class="newsDateTitle">$Date.Nice</ul>
<ul class="newsSummary">$Content.FirstParagraph<a href="$Link" title="Read more on "{$Title}"">Read more >></a></ul>
<% end_control %>
</ul>Thanks in advance.
G
-
Re: Latest articles from multiple Blogs on Homepage required

16 August 2009 at 6:17pm
It is because you are getting 1 blog holder - $news = DataObject::get_one("BlogHolder"); then limiting the next get statement by that ID. Try
function LatestNews($num=5) {
return DataObject::get("BlogEntry", "", "Date DESC", "", $num);
} -
Re: Latest articles from multiple Blogs on Homepage required

17 August 2009 at 6:51pm
Thanks, that worked a treat:-) But that also begs another question, is it possible to specify which Blogs the function queries? This is not an academic question, I could actually use this. It would be useful to be able to have "local" latest blog items lists. But for that I would need to be able to specify the blog to pull the latest 5 articles from.
Cheers -
Re: Latest articles from multiple Blogs on Homepage required

18 August 2009 at 1:16am
Stupid question but for the life of me I cant find homepage.php!! Where is it within the folder structure? Thanks.
-
Re: Latest articles from multiple Blogs on Homepage required

18 August 2009 at 2:30am
@lozhowlett
You have to create it as a page type.
It would be located in /mysite/code/homepage.php (if you put it there).
See the tutorials for help: http://doc.silverstripe.com/doku.php?id=tutorial:1-building-a-basic-site#creating_a_new_page_type
@Beachwalker
Surely using a filter along the lines of (psuedo) ParentId in (id1,id2,id3,...) or if just one, using your original filter would work.That should work, but I haven't tried it. Give it a go, have a play, and if you get something to work, post it back
| 1332 Views | ||
|
Page:
1
|
Go to Top |




