superscral
superscral

Reputation: 480

ezpublish : want to get new comment and delete it

In an ezpublish extension i need to know when a new comment is created and to get all informations about it.

I have seen in a blog that an object can be get with this:

$currentNode = eZContentObjectTreeNode::fetch($nodeId);

but my question is, a comment is a ezContentObject?

And is it possible to delete a comment?

Thanks :-)

Upvotes: 0

Views: 384

Answers (3)

foobar
foobar

Reputation: 916

If your comments are handled as content objects (basically if you don't use eZ Comments), then the latest comment might be retrieved in PHP using the same syntax that you usually use in templates (http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/tree), for instance :

$params = array( 'ClassFilterType' => 'include',
                 'ClassFilterArray' => array( 'comment' ),
                 'SortBy' => array( 'published', true ),
                 'Offset' => 0,
                 'Limit' => 1 );

$lastComment = eZContentObjectTreeNode::subTreeByNodeID( $params, 2 );

Note that you might need to change the class identifier to something different than comment (which is the default one when installing eZ Webin or eZ Flow) and the parent node_id from where you'll browse your content subtree (which in my example is 2.

Then if you want to remove that content, you can take a piece of code in one of these module/views :

  • content/removenode (defined in kernel/content/removenode.php)
  • content/removeobject (defined in kernel/content/removeobject.php)

Take care when removing a content object from your content repository, there are several operations to complete :

  • remove the location(s) (what we call the node(s) actually)
  • remove the object
  • clear the cache in some case

Hope this helps

Upvotes: 1

harmstyler
harmstyler

Reputation: 1401

This really depends on which extension you are using to handle your comments. Generic eZ Publish comments are handled as content. However, the new eZ Comments extension does not treat comments as content and are handled differently. To access eZ Comments you will have to take a look at the eZ Comments classes and module directories. That said, eZ Comments comes prepackaged with template handling, so you should be able to do everything you need to do at the template level.

Upvotes: 0

Nicolas
Nicolas

Reputation: 253

There are several ways of building forums withe eZ Publish, and the answer to your question depends on which one you chose.

Let me fire a couple of questions, that should help us help you :

  • Are you using a default, standard package like "eZ Website Interface" (aka ezwebin), or eZ Flow ?
  • Is the 'ezcomments' extension enabled on your eZ Publish instance ? (you can check this frm the back-office, at the following URL : /setup/extensions )

Cheers,

Upvotes: 1

Related Questions