I'm encountering an issue, which could possibly be a bug, where when publishing a pages cache the methods provided to it's object through a registered extension are not available and therefore the cached page is different to the page which is served up dynamically.
I haven't attempted to reproduce this with a clean install of Silverstripe and the latest version of the staticpublisher extension, so i could be reporting something that isn't a bug but is actually an issue with the code base i'm working on.
Here however is a rough example of what I'm encountering:
Extension:
class SidebarMenuExtension extends DataExtension {
public function testString() {
return 'This is a test string';
}
}
Registering the extension:
Object::add_extension("Page", "SidebarMenuExtension");
Template (hypothetically, Page.ss):
When publishing the page and viewing dynamically, the test string would be output but when viewing the cached file nothing would be output.
I managed to work around this by registering a second extension, 'SidebarMenuExtensionController':
class SidebarMenuExtensionController extends Extension {
public function testString() {
return 'This is a test string';
}
}
Which extends the Extension class (used for extending controllers), and registering it like so:
Object::add_extension("Page_Controller", "SidebarMenuExtensionController");
However this seems a little convoluted so I'm wondering if this is a bug that either exists, used to exist and has been patched (but we havn't upgraded yet) or if this points to a more fundamental issue in the codebase I'm working on, or a fundamental mistake with my knowledge of how SS works.
Aden