Wednesday, 31 August 2016
  3 Replies
  2K Visits
0
Votes
Undo
Hi, first post here, hope this is the right place for my question :)

I have a technical question about the 'inner workings' of JEvent :)
I am the maintainer of the jsSocials plugin. This plugin alows you to add social sharing buttons any where in articles or modules / components where the content plugin is triggered.

It is also possible to auto add buttons on top / bottom / readmore positions in Joomla! articles.
The plugin uses public function onContentPrepare($context, &$article, &$params, $page = 0) to add the buttons.
My plugin checks on the $context to make sure that the buttons are only placed on articles (=com_content.article) and not on other components...

One of my plugin users is using JEvent and my plugin is acting strange...

It adds a whole bunch of buttons on several position in the monthly / detail / year, etc view...

When displaying the debug information on the added buttons, I see that $context = com_content.article....

https://onlinecommunityhub.nl/media/kunena/attachments/935/Selection_162.png

What I would expect is something like com_jevents.monthly etc.

I would really appreciate some insights from your side to understand what is happening here and how to troubleshoot. Would love to see my plugin also handle sites that have JEvent installed correct :)
Wednesday, 31 August 2016 15:38
·
#175025
0
Votes
Undo
Hello,

Geraint is the lead developer here and is out for the afternoon but I'll do my best to be as helpful as possible.

Firstly I would suggest changing line: 164? of your jssocials.php from:


if (strpos($context, "com_content") !== false)


to


if (strpos($context, "com_content") !== false && $category !== null)


This will fix the php error I was getting and only run if there is a category set since the category should always be set in an article anyhow.

Then I would advise you run option checks, to make sure your being run inside the correct component before inserting the social buttons.

The reason we call as com_content.article is to allow the processing of content plugins within JEvents and our modules.

So:


$jinput = JFactory::getApplication()->input;
$option = $jinput->get('option');


$option will return the current component/option it is being run in.

Many thanks
Tony

JEvents Club members can get priority forum support at the Support Forum. As well as access to a variety of custom JEvents addons and benefits. Join the JEvents club today!Join the JEvents club today!

Wednesday, 31 August 2016 15:50
·
#175026
0
Votes
Undo
Hi Tony, many thanks for your thoughts :)
the error 500 I already fixed with the php function class_exists
if (strpos($context, "com_content") !== false && class_exists('ContentHelperRoute'))


When looking at mod_custom you have the advanced option to run content plugins. When setting that option, it runs all content plugins, but the context is still 'mod_custom'.

I will have a look at reading the options / context via JFactory::getApplication()->input;
If that works out okay then this will for sure also prevent other problems arising with other components?

Thanks for looking over my shoulder Tony!
Wednesday, 31 August 2016 16:15
·
#175027
0
Votes
Undo
Yep exactly :-) If you have any further questions, please do not hesitate to ask!

JEvents Club members can get priority forum support at the Support Forum. As well as access to a variety of custom JEvents addons and benefits. Join the JEvents club today!Join the JEvents club today!

  • Page :
  • 1
There are no replies made for this post yet.

Members Area

Show your support

Unlike many Joomla calendars we do not charge to download JEvents - please show your support for this project by becoming a member of the JEvents Club Club members get access to early releases, exclusive member support forums, and Silver and Gold members can use many exciting JEvents addons

Your membership will ensure that JEvents continues to be the best events calendar for Joomla.