OnContentPrepare affecting all plugins

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 201
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

OnContentPrepare affecting all plugins

Post by rgtr » Mon Mar 08, 2021 10:58 am

Hi

I am starting my first plugin - from scratch.
Following the J3.x:Creating_a_Plugin_for_Joomla, and J3.x:Creating_a_content_plugin

It is I hope going just to display a kml file using google maps. Once I have learned J3 then I hope to port to J4.

I am examining, and successfully altering and reducing in size EmbedGoogleMap, KKSou's GoogleMap, Mike Reumers plugin_googlemap3, which I use but it has stopped development, and ZHGoogleMap

Here's the code for my plugin called "tdocgmap", but it is affecting all articles .... one for each different map plugin.

// no direct access
defined( '_JEXEC' ) or die;

class plgcontenttdocgmap extends JPlugin {

public function onContentPrepare($context, &$article, &$params, $limitstart) {

// is it working ?
echo "<br>"."gmap here";
echo "<br>".$limitstart."end";

// need to get api key to start.

return true;
}
}

But in all plugins are now showing the echo'ed text

This seems to be wrong.

What am I doing wrong ?

my xml file, which works well, is as follows:
<?xml version="1.0" encoding="utf-8"?>

<extension version="4.0.0" type="plugin" group="content" method="upgrade">
<name> TDOC Google Maps</name>
<author> Eur Ing Richard Townsend-Rose</author>
<creationDate> February 2021</creationDate>
<copyright> Copyright (C) 2005 - 2021 Open Source Matters. All rights reserved.</copyright>
<license> GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail> [email protected]</authorEmail>
<authorUrl> rgtr.tdocplus.co.uk</authorUrl>
<version> 4.0.0</version>
<description> Plugin to display KML files in Google Maps</description>

<files>
<filename plugin="tdocgmap">tdocgmap.php</filename>
</files>

<!--
<languages>
<language tag="en-GB">language/en-GB/en-GB_tdoc_gmap.ini</language>
<language tag="en-GB">language/en-GB/en-GB_tdoc_gmap.sys.ini</language>
</languages>
-->

<config>
<fields name="params">
<fieldset name="Basic">
<!-- google maps api key -->
<field type="spacer" name="&lt;div style=&quot;color:#fff; font-size:12px; font-weight:bold; padding:3px; margin:0; text-align:center; background:#333333;&quot;&gt;Dimensions&lt;/div&gt;" />
<field name="apikey" type="text" default="enter key" label="Google Maps API Key" description="Google Maps API Key" />
<!-- display dimensions -->
<field type="spacer" name="&lt;div style=&quot;color:#fff; font-size:12px; font-weight:bold; padding:3px; margin:0; text-align:center; background:#333333;&quot;&gt;Dimensions&lt;/div&gt;" />
<field name="width" type="integer" default="500" label="Width" description="" />
<field name="height" type="integer" default="500" label="Height" description="" />
<!-- gmap settings -->
<field type="spacer" name="&lt;div style=&quot;color:#fff; font-size:12px; font-weight:bold; padding:3px; margin:0; text-align:center; background:#333333;&quot;&gt;Dimensions&lt;/div&gt;" />
<field name="zoom" type="integer" default="15" label="Zoom" description="" />
</fieldset>
</fields>
</config>

<updateservers>
<server type="extension" name="Plugin TDOC Googlemap Update Site">http://www.tdopclus.co.uk/tdoc_j4_dev/t ... ml</server>
</updateservers>
</extension>

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 201
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: OnContentPrepare affecting all plugins

Post by rgtr » Mon Mar 08, 2021 11:07 am

Hi
I have added an echo statement in one of the other plugins.
And hey presto that is appearing everywhere ... do I have a corrupt installation, or is this normal.
Richard

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2903
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: OnContentPrepare affecting all plugins

Post by SharkyKZ » Mon Mar 08, 2021 2:20 pm

This is normal.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 201
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: OnContentPrepare affecting all plugins

Post by rgtr » Mon Mar 08, 2021 5:30 pm

Hi
Thanks for that.
The overhead of making all these unnecessary calls might be absolutely huge.
For example on one site I have 20 maps, and 150 calls to Sigplus.
Seems a check needs to be made ...
Richard


Locked

Return to “Joomla! 3.x Coding”