Recent Topics

1 Aug 07, 2009 14:18    

I tried to work through this once and gave up because all my needs were for one installation of a plugin only. I'm talking about the $number_of_installs thing.

I had this idea to do a "canned HTML" plugin. The idea being you would use a plugin to use the Free HTML widget so that you can, effectively, edit the contents of a free HTML widget once (via the plugin) and get all the instances of that widget to change. To do that it would make sense to allow unlimited $number_of_installs eh?

So how do I make each instance of the plugin have a unique name in the plugin list ... and the widget list? Without having a unique name the admin wouldn't know which plugin to edit, and each blog owner wouldn't know which plugin to install as a widget.

I got this project going on that uses a couple of free HTML widgets is the thing. And being lazy I don't want to have to edit each one each time. Can 'em in a plugin and let the code propagate 'em is my theory.

2 Aug 07, 2009 15:29

EdB wrote:

To do that it would make sense to allow unlimited $number_of_installs eh?

Just set it to NULL.

So how do I make each instance of the plugin have a unique name in the plugin list ... and the widget list?

Well, perhaps you could change Plugin::$name dynamically? I know this would be kind of ugly, but I don't know of another way.

3 Aug 07, 2009 16:30

That's what I figured would have to be done, or maybe just leave it out entirely, but then I noticed another problem. The second (and in theory multiple) installation of the plugin doesn't have a 'code' associated with it. I assume because the code is already in use? Anyway when going to the widgets subtab on a blog's settings one sees only one opportunity to select the plugin. That might be related to the lack of code for the subsequent installations?

I just thought of something, which made me think of something else. My mind is so full of shit it should be quite fertile with regard to growing ideas eh? I'm going to ponk around in my head and see if I can't mentally imagine a way to have the plugin make a tools subtab which then creates "free html" bits that can be selected via a widgets subtab. Dunno.

For a cheap answer I could simply make a plugin that gets one installation and is named appropriately for the specific end use in mind, then copy it with new name and code for the next purpose. And so on. Not so bad for someone who is hip to playing inside a plugin, but it'll technically address the root issue I'd like to resolve.

4 Aug 07, 2009 18:00

For the "unique code" bit, this works in whissip

	function PluginInit()
	{
		$this->short_desc = $this->T_('Eventually this will be a working plugin!');
		if( empty( $this->code ) && $this->ID > 0 )
		{
			$this->code = 'amblogmenu_'.$this->ID;
		}
	}

With or without a code I see all instances in widgets.

As an aside, to have unlimited installs it's less coding to not define $number_of_installs in the first place ;)

class am_blogmenu_plugin extends Plugin

{

	var $name = 'AM Blog Menu';
	var $code = 'amblogmenu';
	var $priority = 50;
	var $version = '0.1';
	var $author = 'AstonishMe';
	var $group = 'AstonishMe';
	var $help_url = '';
	var $apply_rendering ='never';


	function PluginInit()
	{
		$this->short_desc = $this->T_('Eventually this will be a working plugin!');
		if( empty( $this->code ) && $this->ID > 0 )
		{
			$this->code = 'amblogmenu_'.$this->ID;
		}
	}

Not tried for unique (definable) title yet, but bets it's easily doable ;)

¥

*edit*
*cough* this comes from the muppet that defines $apply_rendering ... be warned :P

5 Aug 07, 2009 20:03

¥åßßå wrote:

*cough* this comes from the muppet that defines $apply_rendering ... be warned :P

HEY! Are you calling me a muppet?!?!? I always define all the bits. In alphabetical order.

I'll play with it but for now I'll be happy with single-purpose plugins with one instance each.

6 Aug 07, 2009 21:26

EdB wrote:

I always define all the bits. In alphabetical order.

That just makes you an AnalMuppet :|

Widgets used to be able to have custom titles, based on plugin (instance) title, in the widget list though ;)

¥

7 Oct 08, 2009 16:07

I think the code could/should get enumerated automatically, if it's already in use.. - during install of a second instance of the plugin.

8 Oct 08, 2009 16:21

That'd be really smart :)

Throw in having it automagically put a (#) after the name in the plugin list and you got yourself a ... a ... (#) after the name in the plugin list I guess.

With NiBL List I had to give it a second code then change the name to something different is the thing. On the plugins tab and the widget list it gave it the stock name twice - of course - so you just have to know to do that.


Form is loading...