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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

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

Go to End



Community Member, 29 Posts

14 January 2011 at 2:17am


I have a product database and pages connected to that. Done from a tutorial on 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);
} 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