Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Extending Comments Module


Go to End


2 Posts   1134 Views

Avatar
tv

Community Member, 44 Posts

12 June 2013 at 7:44am

I am upgrading my 3.0.4 install to 3.1 and in the process am upgrading to the most up to date release of Willr's comments module.

I would like to edit the CommentsExtension.php file included with the module to achieve the following:
1. Remove the require jQuery call since I l already have jQuery loaded
2. Add additional variables to the template ( in particular a CacheKey variable ).

I have tried creating an extension and overwriting the CommentsForm method:

Class MyCommentsExtension extends Extension {
public function CommentsForm() {
// my overwrite goes here
}
}

and in my config.yml file:
CommentsExtension:
extensions:
- MyCommentsExtension

Unfortunately the system does not seem to be allowing me to extend an extension ( the CommentsExtension file included with the module is already an extension: CommentsExtension extends Extension ).

My question is what is the best way to extend the CommentsExtension file besides hacking it?

Avatar
Willr

Forum Moderator, 5523 Posts

15 June 2013 at 8:26pm

To remove the require call you don't need to hack the module, just include a Requirements::block($Path); call in your application to stop the file from loading.

For the cache key, are you trying to use partial caching? You can override the template in your own theme, the cache key generation could be on your parent controller and the template use $Top to access the cachekey function or write an extension and apply it to the same DataObject as your CommentsExtension. You wouldn't need to apply the extension to an extension, just apply it to the same parent class.