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   302 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, 5513 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.