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.

Data Model Questions /

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


Reply


845 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