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.


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

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

Hacking into PageComments


5 Posts   1908 Views


27 October 2007 at 12:21am Community Member, 501 Posts

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?



27 October 2007 at 1:37am (Last edited: 27 October 2007 1:41am), Forum Moderator, 921 Posts

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!



27 October 2007 at 1:56am Community Member, 501 Posts

Yeah, thanks, that might even be better!

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


27 October 2007 at 2:22am (Last edited: 27 October 2007 2:22am), Forum Moderator, 921 Posts

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! :-)



27 October 2007 at 3:25am Community Member, 501 Posts

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!