7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Pagetype inheriting full db?
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 962 Views |
-
Pagetype inheriting full db?

22 May 2009 at 1:27am
Those are my Page.php and HomePage.php files, cut down to only show the relevant parts. The problem I'm having is on my Home page, it is displaying all of the RelatedLinks from the other pages, and does not have any unique to itself. I can't for the life of me figure out why this is happening...
-
Re: Pagetype inheriting full db?

22 May 2009 at 2:08am Last edited: 22 May 2009 3:45am
EDIT: yea sorry totally misunderstood that one
-
Re: Pagetype inheriting full db?

22 May 2009 at 2:30am
Common problem. You've passed $this as the controller for the DOM, so when it updates your RelatedLink object, by default, it will try to set the foreign key {ControllerPage}ID. When the controller page is a Page object, that works fine (PageID). But when it's a HomePage, or any other subclass of page, that will fail when it tries to set HomePageID on your RelatedLink object.
Solution:
->setParentClass('Page');
-
Re: Pagetype inheriting full db?

22 May 2009 at 2:35am Last edited: 22 May 2009 2:35am
I think I understand, so in Page.php I change $this to $this->setParentClass('Page'), or am I way off?
-
Re: Pagetype inheriting full db?

22 May 2009 at 3:12am
No, you need to run that function on the DataObjectManager
$manager = new DataObjectManager(
...);
$manager->setParentClass('Page');
-
Re: Pagetype inheriting full db?

22 May 2009 at 4:08am
Amazing, it works! Thank you!
//related links tab
$fields->addFieldToTab("Root.Content.RelatedLink",
$manager = new DataObjectManager(
$this,
'RelatedLinks',
'RelatedLink',
array('Title' => 'Title','Address'=>'Address'),
'getCMSFields_forPopup'
)
);$manager->setParentClass('Page');
| 962 Views | ||
|
Page:
1
|
Go to Top |


