Jump to:

3431 Posts in 1058 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » problem with get_by_id("Page"... on pagetype extending dataobject

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

Page: 1
Go to End
Author Topic: 782 Views
  • JMagnusson
    Avatar
    Community Member
    29 Posts

    problem with get_by_id("Page"... on pagetype extending dataobject Link to this post

    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

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