Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Hacking into PageComments

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1897 Views
  • dio5
    Avatar
    Community Member
    501 Posts

    Hacking into PageComments Link to this post

    Hi, I was thinking of using the comments system, but without the built in javascript (I would write my own ) and with my own comment templates.

    Now, instead of modifying it in the core (or better cms/code/sitefeatures) I was thinking of
    just making my own PageCommentInterface.php, based on the original.

    I would put this in mysite/code/ and do something like

    MyCustomPageCommentInterface extends ViewableData
    {

    // here I basically copy everything but change what I need.

    }

    I would probably still use the existing class PageCommentInterface_Form.

    I guess so far this would work, no?

    Then, to get the variable $MyCustomPageComments available in my pagetemplates,
    I would do something like this in the mycustompage_controller

    function MyCustomPageComments()
    {
    return new MyCustomPageCommentInterface($this, 'PageComments', $this->data());

    }

    Now, any thoughts of this? Is this gonna work or does anyone see gigantic flaws already?

    I'm probably going to build in some BBCODE option too, is this going to conflict with akismet or not?

    Thanks!

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Hacking into PageComments Link to this post

    Don't see any problems, however...

    It might be good idea to sub-class PageCommentInterface instead, rather than create your own class, then overload any functions on your custom class that you need. It saves having to rewrite portions you don't need. For example, you won't not need a new __construct() function again, function __construct($controller, $methodName, $page) does what you need already on PageCommentInterface.

    class MyCustomPageCommentInterface extends PageCommentInterface {

    function Comments() {
    // awesome new code goes here, overloading the inherited Comments() function
    }

    // My custom .ss template for this class
    function forTemplate() {
    return $this->renderWith('MyCustomPageCommentInterface');
    }

    }

    Hope this helps!

    Sean

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: Hacking into PageComments Link to this post

    Yeah, thanks, that might even be better!

    Do you think that letting users use BBCODE will make Akismet go crazy?

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Hacking into PageComments Link to this post

    I can't really see it being a problem. Perhaps a search in google for 'akisment bbcode' could provide some answers. From a few quick glances at a few blog sites it appears some people already use url tags etc, and akismet seems to let them through okay.

    Could be worth a quick half hour investigation.

    Good luck with your custom page comments!

    Cheers,
    Sean

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: Hacking into PageComments Link to this post

    Mm, I'm in a doubt right now

    I probably will have to extend the PageComment class also...

    Basically I will only allow members of the website to comment. The members are part of the a Frontend user-group.

    So the name field is not going to be necessary and I'm going to need an 'has_one' - relation on it, page_comment has_one author ( the member), while that member has_many comments...

    Not sure if extending everything would be the best option then.

    Other opinions much appreciated!

    1897 Views
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.