Jump to:

1856 Posts in 1610 Topics by 562 members

Blog Module

SilverStripe Forums » Blog Module » Latest news on home page from two blog holders

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1614 Views
  • Mitz
    Community Member
    9 Posts

    Latest news on home page from two blog holders Link to this post

    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 35

    Any ideas? Thanks people.

  • Willr
    Forum Moderator
    5511 Posts

    Re: Latest news on home page from two blog holders Link to this post

    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.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.