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.

All other Modules

Discuss all other Modules here.

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

Extending Comments Module


Reply

2 Posts   294 Views

Avatar
tv

12 June 2013 at 7:44am Community Member, 44 Posts

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

15 June 2013 at 8:26pm Forum Moderator, 5511 Posts

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.