Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2007-02-26 08:01:23

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Plugin too large - any remedy?

It’s no longer a true plugin if you use that approach, which makes it less easy for users to install.

Offline

#14 2007-02-26 18:25:43

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Plugin too large - any remedy?

There is the “library” type of plugin, you know.

Offline

#15 2007-03-01 01:06:06

nickadeemus2002
New Member
Registered: 2007-02-26
Posts: 4

Re: Plugin too large - any remedy?

can you elaborate on this ‘library’-type plugin??

Offline

#16 2007-03-01 01:26:29

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Plugin too large - any remedy?

If you look in the plugin template provided:

// Plugin types:
// 0 = regular plugin; loaded on the public web side only
// 1 = admin plugin; loaded on both the public and admin side
// 2 = library; loaded only when include_plugin() or require_plugin() is called
$plugin['type'] = 0; 

Once you make your library plugin, you can have it included/required by your main plugin. See functions require_plugin and include_plugin in textpattern/lib/txplib_misc.php (lines 434 -

Offline

#17 2007-03-01 01:37:54

nickadeemus2002
New Member
Registered: 2007-02-26
Posts: 4

Re: Plugin too large - any remedy?

wow. thanks for the quick reply. so to be sure i’m clear with this:

1.) my ‘main’ file would call the include files with the functions you cited.

2.) if my plugin uses one ‘main’ file and several ‘include’ files, they all have to be encoded as “cv_pluginname” files in one zipped/tarred package.

3.) when the end-user uploads this plug-in package via the admin panel, and assuming my “cv_pluginname” package has 4 total files, each file would have to be uploaded via the copy/paste method, then activated.

is this correct? if not, please advise….

thanks so much

chris

Offline

#18 2007-03-01 01:40:25

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Plugin too large - any remedy?

1. Yes.
2 & 3. Sort of. It’s common to name them like ext_plugin_name and ext_plugin_name_lib. The user will have to install both, though, just as you normally install a plugin.

Offline

#19 2007-03-01 01:42:12

nickadeemus2002
New Member
Registered: 2007-02-26
Posts: 4

Re: Plugin too large - any remedy?

Mary,

thank you for pointing me in the right direction.

Offline

#20 2007-03-04 00:26:24

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Plugin too large - any remedy?

Mary wrote:

Once you make your library plugin, you can have it included/required by your main plugin.

I’m using a shared library for my stuff now. I use require_plugin('smd_lib') which, of course, triggers an error if the library is not available. Has anyone found a neat way of catching this situation and offering a decent error message instead? The rest of the page still tries to load and my plugin gives Fatal error: Call to undefined function:.

My hoster uses PHP4 so try...catch is out :-( Short of wrapping every function call in if (function_exists()) is there any way of detecting the failed load at require() time, or intercepting trigger_error or something? As a longshot I tried:

if (!require_plugin('smd_lib')) {
  echo "ARGH!";
}

but it showed ARGH! regardless of plugin state. To be expected after looking at the require_plugin() function and finding it doesn’t return any state information!

I’m localising my plugins with the awesome MLP and it’d be nice to throw a ‘you need to install & enable smd_lib first” in the local language.

Not a deal-breaker, just a nice-to-have if anyone has any pearls of wisdom. Ta!

Edit: duh, I guess I could just do:

require_plugin('smd_lib');
if (!function_exists('one_of_the_functions_in_the_lib')) {
  gTxt('doh');
}

It’ll work I think, but if anyone has anything better, I’m all eyes.

Edit 2: d’oh! except I’ve just remembered that I put my customised gTxt() function in the smd_lib itself so localising the string is fruitless. * smack * has anyone got any of those electric medical paddles so I can reboot my brain?

I’m going to climb back into my box and sulk. Forget I even exist…

Last edited by Bloke (2007-03-04 00:51:10)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#21 2007-03-04 00:47:43

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Plugin too large - any remedy?

Stef

use the load_plugin() function directly yourself and test the return condition. You can find it in the txplib_misc.php file.


Steve

Offline

#22 2007-03-04 01:01:24

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Plugin too large - any remedy?

net-carver wrote:

use the load_plugin() function directly yourself and test the return condition.

Nice one, thanks for the tip Steve. Should have spotted that myself but staring at code all day has frazzled my synapses.

Perhaps I should just give up coding and do something arty… like maybe become a florist.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB