Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Extending Comments Module

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 276 Views
  • tv
    Community Member
    43 Posts

    Extending Comments Module Link to this post

    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:
    - 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?

  • Willr
    Forum Moderator
    5497 Posts

    Re: Extending Comments Module Link to this post

    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.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.