Textpattern Forum

You are not logged in. Register | Login | Help

#1 2011-11-25 17:37:16

MarcoK
Plugin Author
From: Como
Registered: 2006-10-17
Posts: 226
Website

Plugin Callback and Order problem

Hi at all.

I’m doing a Plugin that work with pluggable_ui and categories step().
I have a trouble because i have installed also a smd_write_cat that put a input file after category select.

return $dflt.$catbox;

Where $dflt is the default content.

Now my plugin print only a sting instead of content,

function mck_change_cat($event, $step, $data, $rec){
 return 'I have change categories!';
}
but under this string however appears the categories selects called by smd_write_cat. If i disable this plugin the result is as I want. I have tried to order my plugin as 4 so i think my code was processed before smd_write_cat (order 5) but nothing is changed.

Is normally or there is something wrong

How can I keep the categories change affected even after the smd plugin?

Offline

#2 2011-11-25 20:08:30

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,927
Website

Re: Plugin Callback and Order problem

MarcoK wrote:

I have tried to order my plugin as 4 so i think my code was processed before smd_write_cat (order 5) but nothing is changed.

Very odd. I would expect the callbacks to fire in plugin load order. My plugin only appends to whatever is there already, so if yours has altered the category selects then mine should just add to whatever is returned from your plugin.

Must admit I’ve never tried chaining plugins this way. Perhaps it’s a bug, unless someone else can fathom out a reason why it would behave this way.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2011-11-25 21:00:06

Gocom
Developer
Registered: 2006-07-14
Posts: 4,476
Website

Re: Plugin Callback and Order problem

Bloke wrote:

Very odd. I would expect the callbacks to fire in plugin load order. My plugin only appends to whatever is there already, so if yours has altered the category selects then mine should just add to whatever is returned from your plugin.

That seems what is designed to happen. Hooks can only replace the default content, not content added by other hooked functions. Content returned by hooks is always added to the existing content added by other hooks, and modifications are not passed from a hook to other.

If I understood MarcoK correctly, he wants the opposite. As I read it, he to want to modify the default content, and pass the modified default content to other hooked functions (i.e. smd_write_cat). Which unfortunately is not supported.

The default content the plugins get from the callback is what was originally there. As smd_write_cat returns the default content in addition of added functionality, the changes MarcoK have no effect. The fields he removed will just come back.

Last edited by Gocom (2011-11-25 21:07:46)


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#4 2011-11-26 09:05:58

MarcoK
Plugin Author
From: Como
Registered: 2006-10-17
Posts: 226
Website

Re: Plugin Callback and Order problem

Bloke wrote:

… My plugin only appends to whatever is there already, so if yours has altered the category selects then mine should just add to whatever is returned from your plugin.

This is what I thought would happen.

Hum… ok, so… Dev can use this ‘bug’ and resolv it on TXP 5 no? Is an Idea…

My only solution is insert a jquery script that modify category’s select

Offline

#5 2011-11-26 20:39:19

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,927
Website

Re: Plugin Callback and Order problem

Gocom wrote:

Hooks can only replace the default content, not content added by other hooked functions

Shame. We should probably look into ways to chain things in future then. Granted it opens up some glaring problems if Plugin 1 removes some content that Plugin 2 relies upon, but if we handle it carefully it might be possible. Maybe some configuration option or a per-plugin switch that admins can use.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB