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.

Data Model Questions /

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

problem with get_by_id("Page"... on pagetype extending dataobject


Go to End


1358 Views

Avatar
JMagnusson

Community Member, 29 Posts

14 January 2011 at 2:17am

Hello

I have a product database and pages connected to that. Done from a tutorial on ssbits.com so I dont understand everything. But the product pages are created via CategoryPage.php with "renderWith". Now I have a sidebar on every page, and I want to have it on the product pages to. A treeDropDownField lets the user chose a page in sitetree and stores the pageID in the database. Then this function...
function SideBarPage() {
return DataObject::get_by_id("Page", $this->SideBarPage);
}
...is called from a control on the main page, and the page content from the chosen side bar page is pasted. It works fine on page types extending sitetree, but it dont work whether when I paste the function the "class CategoryPage_Controller extends Page " where the "renderWith"-function is located, or from "class CategoryPage extends Page" nor "class Product extends DataObject" where the database field is.

Someone who knows the right way to do it?

Thanks, Johan