×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Is there a document to develop plugins?

Is there a document to develop plugins? 14 years 9 months ago #5112

  • Jaime
  • Jaime's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0
Hello.... I have created a custom component for Joomla 1.5 and now I need to add the possibility for visitors to add comments to the content thay are viewing (this content is not stored in jos_content table), so I think I can develop a custom plugin for JoomlaComment, can't I?

Well... If I can, is there a document that teaches how to develop plugins for JoomlaComment?

Thanks
Jaime

Is there a document to develop plugins? 14 years 9 months ago #5118

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Joomlacomment beta1 is coming with an empty dummy plugin. Look at it and you will understand what functions to fill for you component.

Is there a document to develop plugins? 14 years 8 months ago #5323

  • Jaime
  • Jaime's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0
Hello Daniel... thanks for answering... I used the dummy plugin but something is wrong with it. Maybe I need to configure something.

I replaced where the word REPLACE appeared in both plugin files but the comment section wasn't shown.

the problem was in:
$comObject = JOSC_utils::ComPluginObject($option, $this->proyecto);
echo JOSC_utils::execJoomlaCommentPlugin($comObject, $this->proyecto, $this->param, true);

where $option is the name of the component: com_hum

In that case, the call to JOSC_utils::boardInitialization in execJoomlaCommentPlugin set $exclude variable to be true so that $board->visual_htmlCode() is not get called actually.

If I use $option = '' in calling to ComPluginObject, exclude returns false, but the plugin class that is called is josc_com_content.class.php instead of my class. It seems that when I don't pass an $option, com_content is hardcoded.

Am I missing something? When I pass $option = 'com_hum', $config->load() in JOSC_properties returns false. It seems that I have to configure something somewhere.

Any further help will be greatly appreciated.

Thanks
Jaime

Is there a document to develop plugins? 14 years 8 months ago #5327

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Did you call the plugin in your extension. You should have
<?php
require_once(JPATH_SITE."/administrator/components/com_comment/plugin/yourplugin/yourplugin.php");
?>

in yourplugin.php you can make
$option = JRequest::getCmd('option');
this will get the option from the url.
require_once(JPATH_SITE . DS . 'components' . DS. 'com_comment' . DS . 'joscomment' . DS . 'utils.php');
$comObject = JOSC_utils::ComPluginObject($option,$this->proyecto);

do you have data in $this->proyecto ?

You will also have to enable the plugin from the backend :) Other compoentn plugins -> new then a new plguin for proyecto and then you should see a result in the frontend :)

Is there a document to develop plugins? 14 years 8 months ago #5331

  • Jaime
  • Jaime's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0
I think the last step is missing, but I could not find where it is.

By tracing the component code, I saw that I need to add an entry to jos_comment_setting table, but if I add one, the ID #1 is assigned, and that ID was reserved for com_content object, caused of this lines in library.comment.php:
function getComponentList($set_id=0)
{
$list = array();
if ($set_id==1) {
	    $list[] = JHTML::_('select.option', '', 'com_content');
 
	} else {

If I force the ID to be other number, the page breaks completely, only the header of the component administrator is shown with no styles. Neither the Joomla menu is shown in that case.

In Joscomment administration I have 6 menu options: Manage comments, content settings, import comment, other components settings, JoomVertising and about. In other components settings only com_content is feasible to be configured.

Where is the New option you are talking about? Please see the attached screendshot.

Is there a document to develop plugins? 14 years 8 months ago #5333

  • Jaime
  • Jaime's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0
Finally it worked! it was due to the following line in the demo plugin:
function getCategoriesIdOption() 
    {	
    	global $database;
 
    	$catoptions = array();
 
		return $catoptions;
    }

The problem is that there is no $database global object. Therefore I used
$database = JFactory::getDBO();

instead, as the com_content plugin does.

The same happens with the folowing method in demo plugin:
    function cleanComponentCache() {
            mosCache::cleanCache( 'com_REPLACEnewplugin' );
    }

There is no mosChache object, so I used:
    function cleanComponentCache() {
		$cache =& JFactory::getCache('com_hum');
		$cache->clean('com_hum');
    }

But I am still wondering how to add the new plugin without editing the database table directly.

Thanks
Jaime

Is there a document to develop plugins? 14 years 8 months ago #5334

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Click save, then you will have the new option :)

Is there a document to develop plugins? 14 years 8 months ago #5335

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Yep, I saw that the dummy plugin is not updated. Sorry about that. In joomla 1.5 there is no global $database object.
I've updated the dummy file and it will be included in beta2 :)
  • Page:
  • 1
Time to create page: 0.134 seconds