Hi all,
I have an extension A (which includes a component and a mambot) that does a number of things and works very well for me, except one part of its functionality. For that functionality I have a plugin B which does things how I like it. However, for reasons of layout and of where the extension and plugin appear, I would like to put that plugin B in the place where extension A produces similar functionlity.
I had a look at the php files of both, and saw that both basically have functions which lead to one or another output of html. Since plugin B is a mambot I thought I would simply do a php echo of the mambot name in curly brackets, i.e. {pluginb}, in the php file that prodiuces the html output of extension A. I do not know why this did not work, but my guess was that perhaps there is some special code a mambot has to have to be called in the {mosplugin} way?
Then I just copied the html output of plugin B into the php file that prodiuces the output of extension A. Expectedly that gave me the appearance but not the functionality of plugin B, because the php functions of plugin B were not available in the php of extension A.
Is there a simple way in which I can do this? What I was really hoping for is that I would be able to call plugin B from within the extension A html output in the same way as one would call a plugin in content text by using curly brackets, like {mosimage}.
Any help is appreciated!
how to call one extention in another
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
Forum rules
Re: how to call one extention in another
Hi,
might be helpful to known with which version of Joomla! are you working with.
anyhow: "mambots" (J! 1.0) or "plugins" (J! 1.5) are bound to certain Events, triggerend by the application OR a component. If the plugin youre trying to reuse is usually bound to a specific event, nothing will happen, if you component doesn't trigger the appropriate event. The plain existance of some {foobar} placeholder anywhere in a component's output will do nothing.
In addition, the scope of a plugin is determined by the group it belongs to. Some "content" plugins won't be loaded at all if there is no "content" (~ com_content) to display. In J! 1.5 this happens in each of the views (search for JPluginHelper::importPlugin ).
For example, the "pagebreak" plugin only works for the com_content component as it triggers the relevant Events which causes the {pagebreak} placeholder (or
elements in 1.5) to be replaced with specific HTML by that very plugin. if it's *told* to do so, by something triggering the onPrepareContent or onBeforeDisplayContent Events in time. com_content does so for every plugin in the "content" group with a variety of events.
Take a look at the code of "pluginb" to learn what event(s) it's actually registered for, then trigger that event in you component, i.e.
$mainframe->triggerEvent('onWhatever');
That alone might not help however, as each plugin expects certain data to work with and your component must proide the corrent arguments to the event handler functiions.
You may alternatively try to include "pluginb" yourself and simply use its code like any other "library".
Have fun,
CirTap
might be helpful to known with which version of Joomla! are you working with.
anyhow: "mambots" (J! 1.0) or "plugins" (J! 1.5) are bound to certain Events, triggerend by the application OR a component. If the plugin youre trying to reuse is usually bound to a specific event, nothing will happen, if you component doesn't trigger the appropriate event. The plain existance of some {foobar} placeholder anywhere in a component's output will do nothing.
In addition, the scope of a plugin is determined by the group it belongs to. Some "content" plugins won't be loaded at all if there is no "content" (~ com_content) to display. In J! 1.5 this happens in each of the views (search for JPluginHelper::importPlugin ).
For example, the "pagebreak" plugin only works for the com_content component as it triggers the relevant Events which causes the {pagebreak} placeholder (or
elements in 1.5) to be replaced with specific HTML by that very plugin. if it's *told* to do so, by something triggering the onPrepareContent or onBeforeDisplayContent Events in time. com_content does so for every plugin in the "content" group with a variety of events.
Take a look at the code of "pluginb" to learn what event(s) it's actually registered for, then trigger that event in you component, i.e.
$mainframe->triggerEvent('onWhatever');
That alone might not help however, as each plugin expects certain data to work with and your component must proide the corrent arguments to the event handler functiions.
You may alternatively try to include "pluginb" yourself and simply use its code like any other "library".
Have fun,
CirTap
Last edited by CirTap on Fri Nov 09, 2007 12:38 pm, edited 1 time in total.
You can have programs written fast, well, and cheap, but you only get to pick 2 ...
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams
Re: how to call one extention in another
Thanks for your response CirTap!
I guess using the terms mambot and plugin was confusing.. the Joomla version I use is the latest 1.x so I suppose mambot is the right term.
The component puts out pages with the normal content items between some extra information above and below it, and if my understanding is right then it does so through a mambot. I have been customising the information above and below quite a bit, and now I would like to put the output of the other mambot in the middle of the information above the content items.
The mambot is a content mambot and it is triggered 'onBeforeDisplayContent'.
I suspect that if I would trigger this event the mambot would place itself at the top of the page where it displays itself now. But then again, I am understanding so little of how this all works that I would not even know where to place the trigger!
Basically the mambot I am trying to insert at will is a voting mambot, and I am trying to achieve something similar to a voting mambot I found somewhere which can be placed in the content with a tag like {myvote}. Unfortunately that mambot did not work when I installed it, but anyway I expect that it would not be such a clever mambot as the one I am trying to use, the AJAX voting plugin, and I also wonder if I would be able to simply echo html with that tag in the php creating the component's output.
I guess using the terms mambot and plugin was confusing.. the Joomla version I use is the latest 1.x so I suppose mambot is the right term.
The component puts out pages with the normal content items between some extra information above and below it, and if my understanding is right then it does so through a mambot. I have been customising the information above and below quite a bit, and now I would like to put the output of the other mambot in the middle of the information above the content items.
The mambot is a content mambot and it is triggered 'onBeforeDisplayContent'.
I suspect that if I would trigger this event the mambot would place itself at the top of the page where it displays itself now. But then again, I am understanding so little of how this all works that I would not even know where to place the trigger!
Basically the mambot I am trying to insert at will is a voting mambot, and I am trying to achieve something similar to a voting mambot I found somewhere which can be placed in the content with a tag like {myvote}. Unfortunately that mambot did not work when I installed it, but anyway I expect that it would not be such a clever mambot as the one I am trying to use, the AJAX voting plugin, and I also wonder if I would be able to simply echo html with that tag in the php creating the component's output.
Re: how to call one extention in another
Hi,
saying you use the "latest 1.x" doesn't make it any clearer, and would mean 1.5.0 -- which is as much of a "1.x" version as 1.0.13 ;-)
However, as you speak of mambots anyway, I assume you use 1.0.13, which is the latest 1.0.x release
So, well, whatever the tag is call that mambot is looking for ({mosvote}?), typical behaviour is to substitute it "in place" with different content/data, like the {mospagebreak} or {mosimage} bots do. It should not output below the content, unless this *is* how the mambot works by design, and of course it's free to do anything to the $row data it gets from the event dispatcher.
If you haven't yet, just trigger "onBeforeDisplayContent" someplace suitable in your component and see what happens :-) It should do something -- at least yell about wrong or insufficient data. Study the code to find if it expects any particular data structure.
CirTap
saying you use the "latest 1.x" doesn't make it any clearer, and would mean 1.5.0 -- which is as much of a "1.x" version as 1.0.13 ;-)
However, as you speak of mambots anyway, I assume you use 1.0.13, which is the latest 1.0.x release
So, well, whatever the tag is call that mambot is looking for ({mosvote}?), typical behaviour is to substitute it "in place" with different content/data, like the {mospagebreak} or {mosimage} bots do. It should not output below the content, unless this *is* how the mambot works by design, and of course it's free to do anything to the $row data it gets from the event dispatcher.
If you haven't yet, just trigger "onBeforeDisplayContent" someplace suitable in your component and see what happens :-) It should do something -- at least yell about wrong or insufficient data. Study the code to find if it expects any particular data structure.
CirTap
You can have programs written fast, well, and cheap, but you only get to pick 2 ...
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams