Hey Andrei,
Sorry about the delay.
Check this thread out:
compojoom.com/forum/45-newbies-area/14806-component-integration
- I think that it will also help you.
So basically have a look at the existing plugins in
administrator/components/com_comment/plugin
Let us look at the com_k2 folder. I'll explain how that plugin works - you'll have to do the same for your component... (create a new folder for the component, rename the k2 files to josc_com_yourcomponent.php ... and change the class names and funcitons inside those files)
There we have 2 files:
josc_com_k2.php
josc_com_ks.class.php
you need to include the josc_com_k2.php file in your component.
and do:
echo CommentPluginK2::output($row, $params);
$row in the code above is the object that contains the id and catid for the music item.
This code here:
class CommentPluginK2 {
public function output($row, $params)
{
$comObject = JOSC_utils::ComPluginObject('com_k2', $row, 0, $row->catid);
$comments = JOSC_utils::execJoomlaCommentPlugin($comObject, $row, $params, true);
unset($comObject);
return $comments;
}
}
will automaticall call the josc_com_k2.class.php file and the JOSC_com_k2 class.
Here is a small review of what the functions in class do:
checkSectionCategory - this function decides whether it should execute the component at all (depending on the settings in the backend. (include/exclude categories))
checkVisual - if checkSectionCategory returns true then the this function will be called - it will decide if it should show a comment form or count button (write comment( 10 comments))
if you have those 2 correct -> then you should already see a form in single view of your component and you should be able to leave a comment.
createFeed - this function will create the rss feed - if you don't use RSS then there is no need to write this function
linkToContent - this is actually in my opinion the most important function -> it creates links to the comments. (in email, in the module, in backend on the frontend - so it should create correct links to the items)
cleanComponentCache -> cleans the cache after a user inserts a comment
getCategoriesIdOption, getObjectIdOption, getViewTitleField, getViewJoinQuery - those are all used in the backend -> for comment list, edit comment etc
mod_commentsGetMostCommentedQuery, mod_commentsGetOthersQuery - are used in the module - depending on the module settings.
My general advise is - set php error reporting to maximum - this way you can see the fatal errors when you develop and this will give you a clue what you are missing. (not just a blank screen)
Let me know how it goes! If you get stuck somewhere don't hesitate to write! I want to add this information to the documentation, so if you have ideas how to write everything better, please share!
Regards,
Daniel