Page 1 of 1
check if mambot is published
Posted: Sun Oct 07, 2007 11:23 am
by yoshi
hi, whats the best way to check if the mambot id published or not.?
I see a lot of mambots which still interfere with stuff evn when they are unpublished (you actually have to remove the mambot to stop it)!
So whats the code or syntax to do it properly?
Many thanks
Lee
Re: check if mambot is published
Posted: Sun Oct 07, 2007 12:46 pm
by yoshi
Re: check if mambot is published
Posted: Sun Oct 07, 2007 2:14 pm
by AmyStephen
If you look at the code for the loadmodule plugin (plugins/content/loadmodule.php), you will find this code:
Code: Select all
// check whether plugin has been unpublished
if ( !$pluginParams->get( 'enabled', 1 ) ) {
$row->text = preg_replace( $regex, '', $row->text );
return true;
}
Hope that helps!
Amy
Re: check if mambot is published
Posted: Mon Oct 08, 2007 9:00 am
by yoshi
Amy, thanks for the reply. I have looked in several mambots but as I am not a coder I dont realy understand whats going on ;-(
I have managed to put together a mambot which does exactly what I want and the code I posted above sems to work but your seems to be a better guide.
However, as I dont know what it means, a plain english translation of your above code would be:-
Code: Select all
check if mambot is published - if yes do the replace - end?
where should this go in the code? if you put it at the very bottom of the mambot function would that not put an overhead on the page load (even with the mambot unpublished) as the whole function would still be performed before deciding not to output the result?
I hope I am making sense.
Thanks again for any help
Re: check if mambot is published
Posted: Mon Oct 08, 2007 7:36 pm
by AmyStephen
Yoshi -
I am also just learning. The best way, IMO, to learn is to study an existing, working example. The code snippets I shared with you came directly from the plugins\content\loadmodule.php file in the Joomla! core.
That code is saying if the plugin is NOT enabled (not the ! in front of the phrase), then remove the {loadposition}xxx{/loadpostion} syntax in the article with nothing and exit the plugin.
I've used loadmodule over and over and over.
Good luck with your project and I hope you are having fun like I am!
Amy
Re: check if mambot is published
Posted: Tue Oct 09, 2007 8:19 pm
by Pentacle
Amy, I am a little bit confused here. If a plugin is unpublished it shouldn't be executed at all.
But wait, loadmodule plugin is not written in the new way of 1.5. I think the old way doesn't handle the publishing itself, right?
Re: check if mambot is published
Posted: Tue Oct 09, 2007 9:12 pm
by yoshi
exactly my point Pentacle. it seems a lot of mambots for 1.0 actually get 'processed' for want of a better term even if their results are not output to the screen.
Re: check if mambot is published
Posted: Tue Oct 09, 2007 9:48 pm
by AmyStephen
Pentacle wrote:Amy, I am a little bit confused here. If a plugin is unpublished it shouldn't be executed at all.
But wait, loadmodule plugin is not written in the new way of 1.5. I think the old way doesn't handle the publishing itself, right?
Is that so? Hmm. I don't know. I have been using loadmodule as an example.
Do you know of a good example of the new way?
Thanks!
Amy
Re: check if mambot is published
Posted: Wed Oct 10, 2007 8:01 am
by Pentacle
AmyStephen wrote:Is that so? Hmm. I don't know. I have been using loadmodule as an example.
Do you know of a good example of the new way?
Thanks!
Amy
Hmm. Most of the core plugins (especially content) ain't touched since 1.0 I think. So Ian's slider plugin or my youtube one (not *good* but a simple example
) can show this behavior. I didn't use these checks about plugin is published or not. But when I disabled it, replacement wasn't taking place.
Ercan.
Re: check if mambot is published
Posted: Fri Oct 12, 2007 6:37 pm
by DeanMarshall
Just to clarify one point - mambots/plugins are executed even when unpublished
to allow the module - where necessary - to remove the { ... } mambot tag so
as to tidy up display.
Dean
Re: check if mambot is published
Posted: Fri Oct 12, 2007 7:26 pm
by AmyStephen
Even for J! v 1.5? I realize it does so in v 1.0.x but it seems like v 1.5 might be different. Otherwise, we would continue to need to check if were published, or else it would go ahead and run simply because it was installed.
Nice to see you, Dean, and I appreciate your response, always.
Amy
Re: check if mambot is published
Posted: Fri Oct 12, 2007 9:57 pm
by Pentacle
Right now, I'm playing with some 1.5 plugins and if it's not published, I can't do anything. Not echoing, not replacing. An explanation from the core team would be great.
Re: check if mambot is published
Posted: Fri Oct 12, 2007 11:37 pm
by DeanMarshall
AmyStephen wrote:Even for J! v 1.5? I realize it does so in v 1.0.x but it seems like v 1.5 might be different. Otherwise, we would continue to need to check if were published, or else it would go ahead and run simply because it was installed.
Nice to see you, Dean, and I appreciate your response, always.
Amy :)
Hi Amy,
My comment was an off the cuff 'in general' - just trying to explain
the situation from my experience, which is mainly J1.0.x - I haven't
really dabbled that much with J1.5
A quick check of the pagebreak plugin shows this:
Code: Select all
// check whether plugin has been unpublished
if ( !JPluginHelper::isEnabled('content', 'pagebreak') ||
$params->get( 'intro_only' )||
$params->get( 'popup' ) ||
$full)
{
$row->text = preg_replace( $regex, '', $row->text );
return;
}
Which according to the comments checks whether the plugin is unpublished
and if it is or we are on a page showing intro text only, or in a popup the
plugin tag is replaced by the empty string.
Dean
Re: check if mambot is published
Posted: Fri Oct 12, 2007 11:51 pm
by AmyStephen
That's what we were noticing, as well, but we were wondering if really the plugins could be updated to remove that logic.
You know, Dean, v 1.5 is a whole lot of fun to play with. Hope you are able to find time to play soon!
Amy