21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 689 Views |
-
Inherit data from parent?

14 March 2009 at 7:30am
Let's say I have a Page (Page class) called Susan. On this page is a tab called 'Favorites' and on that tab, is a text field called 'Favorite song'.
What I want to achieve, is that when a subpage is created under Susan, say page 'Donna', Donna inherits Her parents favorite song but can later change this.
Ideas?
-
Re: Inherit data from parent?

14 March 2009 at 10:02am Last edited: 14 March 2009 10:03am
Hi Rob
If you are using 2.3 then you can use the onAfterWrite() function in your page model. Something like this should work:
function onAfterWrite() {
parent::onAfterWrite();
$this->FavouriteSong = $this->Parent()->FavouriteSong;
}
| 689 Views | ||
|
Page:
1
|
Go to Top |


