Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » [[edited]] including code within a function

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 881 Views
  • bmc38119
    Avatar
    Community Member
    45 Posts

    [[edited]] including code within a function Link to this post

    using the tutorial code as an example, is it possible to call a function from an include file on

    /**
    * Defines the HomePage page type
    */

    class HomePage extends Page {
    static $db = array(
    );
    static $has_one = array(
    );

    }

    class HomePage_Controller extends Page_Controller {

    function LatestNews() {
    include('FunctionLatestNews.php')
    }   

    }
    ?>

    where FunctionLatestNews.php contains the following code:

    $news = DataObject::get_one("ArticleHolder");
    return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", 5) : false;

    just thinking where this code could be reused on other page controllers.

    881 Views
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.