Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Use of DataObject::

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: 1117 Views
  • Charly
    Avatar
    Community Member
    6 Posts

    Use of DataObject:: Link to this post

    O.K, newbie question.

    I have put the following code into a Page called NewPage.php:

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

    static $has_one = array(
    );

    }

    class NewPage_Controller extends Page_Controller {

    function newFunction1() {
    return DataObject::get("Page", "ParentID=0");
    }

    }

    In NewPage.ss I call newFunction1 by using:

    <% control newFunction1 %>

    <li><a href="$Link" title="Go to the $Title.XML page"><span>$MenuTitle.XML</span></a></li>

    <% end_control %>

    When I then access the page, I get the following error:

    ERROR:
    Error
    The website server has not been able to respond to your request.

    What have I missed?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Use of DataObject:: Link to this post

    well first - open _config.php and add Director::set_environment_type("dev"); so you can see a more useful error apart from the blank error page!

  • Charly
    Avatar
    Community Member
    6 Posts

    Re: Use of DataObject:: Link to this post

    Thanks, the extra debugging info is very helpful. I rebuilt the page it works fine. I think I had a typo....

    1117 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.