1

I want to display social share plugin in MediaStore component but my skills are not high enough to make it work. Can somebody give me some clues on how to do this?

This is how I tried to call the plugin:

jimport('joomla.plugin.plugin');
class plgMediaStoreJoomla extends JPlugin {

    /**
     * Constructor.
     *
     * @param   $subject
     * @param   array $config
     */
    function __construct(&$subject, $config = array()) {
        // call parent constructor
        parent::__construct($subject, $config);
    }



    /**
     * onMSProductBeforeDisplay hook.
     */
    public function onMSProductBeforeDisplay($context, &$item, &$params) {

        JPluginHelper::importPlugin('content', 'social_share');
        $dispatcher = JEventDispatcher::getInstance();
        $app = JFactory::getApplication('site');
        $app->initialise();
        $app->triggerEvent('onContentAfterTitle');

        $versions   = $item->params->get('joomla_versions');

        if (is_array($versions) && count($versions)) {
            JHtml::_('stylesheet', 'plg_mediastore_joomla/style.css', array(), true);

            $html   = array();
            $html[] = '<div class="joomla-versions">';

            foreach ($versions as $version) {
                $html[] = '<span class="joomla-' . $version . '">Joomla! ' . $version . '</span>';
            }

            $html[] = '</div>';

            return implode("\n", $html);
        }

        return '';
    }

But I get those errors:

Warning: Missing argument 1 for plgContentsocial_share::onContentAfterTitle() in..

Trying to get property of non-object in..

Notice: Undefined variable: context in..

etc

3

Reference here: https://docs.joomla.org/Triggering_content_plugins_in_your_extension

in $app->triggerEvent('onContentAfterTitle'); you need to pass some arguments as an array, and you have not passed them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.