This has probably been asked before, but I could not find a solid link for this. According to http://doc.silverstripe.org/doku.php?id=page-types
- page_controller is the controler. Functions defined on the controller are only available when you actually visit the page
- page is the dataobject. Any method on the dataobject is available whenever the object is referenced in the system
I am wondering what goes where and why and what the benefits are of placing it in one or the other.
As an example: Since the children of my Page-class share common methods I define them in the Page.php. But: I have discovered certain functions can be placed in the dataobject or in the controller where others have to be in the dataobject
1. I have a function that extracts a shorter version of the Content field so it can be displayed in another page with a 'do you want to read more'-link. I can understand that this can ONLY be in the dataobject because I have to extract the data from that page even when the page is not visited itself.
2. I extract the data for the footer of every page from a page called 'Footer' of class 'FooterOfPage' using DataObject::get_one('FooterOfPage'). Wit this method I do not access the page, I access the database. I can put that method in the controller OR in the dataobject. Is there a difference? If I put it in the dataobject, I can also access the function when in the cms - if I have to. Is that correct? Is that the only difference?