Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Use of DataObject::


Go to End


3 Posts   1431 Views

Avatar
Charly

Community Member, 6 Posts

7 March 2008 at 2:29pm

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?

Avatar
Willr

Forum Moderator, 5523 Posts

7 March 2008 at 9:20pm

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!

Avatar
Charly

Community Member, 6 Posts

10 March 2008 at 11:53am

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