开发者

call plugin in joomla component

开发者 https://www.devze.com 2023-02-28 06:24 出处:网络
How can i call joomla \'Simple Picture Slideshow\' plug开发者_StackOverflow社区in in any joomla component. Have any solution?

How can i call joomla 'Simple Picture Slideshow' plug开发者_StackOverflow社区in in any joomla component. Have any solution?

Thanks


Best way to call content plugins in Joomla! 1.5 and above is just use:

$text = JHTML::_('content.prepare', $text);

http://docs.joomla.org/Triggering_content_plugins_in_your_extension


You can call any event of plugin which is defined in that plugin.

$dispatcher = JDispatcher::getInstance();
$data = array($argu1, $argu2);   // any number of arguments you want
return $dispatcher->trigger($eventName, $data);


In Joomla, plugins are not called in the typical sense, they are triggered by various events. The plugin listens for the particular event that triggers it. In this case, you would need to look and see what even Simple Picture Slideshow listens for, then add that trigger to your component. The only way to guarantee that a plugin will be triggered all the time is have it listen for one of the global system events, these happen regardless of the code in the component, they happen at the framework level. If a plugin is triggered by a non-global event, then you would need to either change the plugin or add the event to every component you want using the plugin.

Global system event reference - http://docs.joomla.org/Reference:System_Events_for_Plugin_System

Plugin reference - http://docs.joomla.org/Plugin


This question is specifically for Content plugin of joomla.

You can trigger any plugin event in your component.

Here is an example to trigger content plugin onPrepareContent event.

$content = new stdClass;
$content->text = 'Your content body with proper tag or 
                    content wich you want to replace. 
                    For example:  {loadmodule mod_login}';
$atricle = array();

JPluginHelper::importPlugin('content');
$dispatcher = JDispatcher::getInstance();

JDispatcher::getInstance()->trigger(
    'onPrepareContent',
    array(
        &$content,
        &$atricle,
        null
    )
);

Or if you want to trigger only specific plugin for your component, then you can use,

JPluginHelper::importPlugin('content', 'loadmodule');

Second argument is name of the plugin which you want to use.

Similarly, you can call user plugin event in your component.

JPluginHelper::importPlugin('user', 'contactcreator');

JDispatcher::getInstance()->trigger(
    'onUserAfterSave', 
    array(
        $user, 
        $isnew, 
        $success, 
        $msg
    )
);
0

精彩评论

暂无评论...
验证码 换一张
取 消