18/03/2012 10:22pm

PHP | Problem - How to override a method?


// We have core code which defines the location options for images in the CMS in Page.php

// Other page types can over-write these location options


// Page.php
class Page extends SiteTree{

function getLocationOptions()
{
return array(
"none" => "Do not display",
"default" => "Default"
);
}

}


// CustomPage.php
class CustomPage extends Page{

function getLocationOptions()
{
return array(
"belowtitle" => "Below page title",
"belowcontent" => "Below page content",
"default" => "Default"
);
}

}

//How do I override getLocationOptions across all Pages without editing Page.php (which is part of our core code and shared by many projects)?


Post Comment