1776 Posts in 498 Topics by 533 members
Blog Module
SilverStripe Forums » Blog Module » Latest news on home page from two blog holders
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1370 Views |
-
Latest news on home page from two blog holders

21 May 2010 at 4:59pm
Hi there,
I have two blogs that I'm using on a current build. Wish to show latest posts from both these blogs on the home page. eg. 2 under Latest News and 1 under Latest Research.
I can see how to specify the blog from: http://www.silverstripe.org/blog-module-forum/show/261584#post261584. However when I try to add both to my code, I get the following error:
Fatal error: Cannot redeclare HomePage_Controller::LatestNews() in /home/fxmed/public_html/silverstripe/mysite/code/HomePage.php
on line 35Any ideas? Thanks people.
-
Re: Latest news on home page from two blog holders

21 May 2010 at 8:17pm
You can't have 2 functions called the same. Either rename the 2nd one or use pass an argument to work out which holder to use. For example if you did <% control LatestNews(blog) %> and <% control LatestNews(news) %> and you could use 1 function to do both and just swap on the variable you pass
function LatestNews($title) {
$news = DataObject::get_one('ArticleHolder', "URLSegment = '$title'");return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", '', 10) : false;
}That 2nd line will get you the article holder by the URL you pass into the function.
| 1370 Views | ||
|
Page:
1
|
Go to Top |


