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.

Archive /

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

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

Hacking into PageComments


Reply


5 Posts   1944 Views

Avatar
dio5

Community Member, 501 Posts

27 October 2007 at 12:21am

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!

Avatar
Sean

Forum Moderator, 922 Posts

27 October 2007 at 1:37am

Edited: 27/10/2007 1:41am

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

Avatar
dio5

Community Member, 501 Posts

27 October 2007 at 1:56am

Yeah, thanks, that might even be better!

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

Avatar
Sean

Forum Moderator, 922 Posts

27 October 2007 at 2:22am

Edited: 27/10/2007 2:22am

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

Avatar
dio5

Community Member, 501 Posts

27 October 2007 at 3:25am

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!