Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2017-10-19 10:15:46

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

[Solved] Get callback related variables

Hi,
Is there an obvious reason why $newname would be undefined when trying to register a function on the page_saved event?

class abc_my_plugin
{
    public function __construct()
    {
        register_callback(array($this, 'test'), 'page_saved');
    }

    public function test($event, $step, $pre, $name, $newname)
    {
        …
    }
}

new abc_my_plugin();

Thanks for your help!

Last edited by NicolasGraph (2017-10-20 10:29:41)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#2 2017-10-19 12:23:03

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: [Solved] Get callback related variables

Ok, it seems I just need to remove `$pre`.

Last edited by NicolasGraph (2017-10-19 12:25:39)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#3 2017-10-19 12:50:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,787
Website

Re: [Solved] Get callback related variables

Yeah, ‘pre’ is used when setting up the register_callback to tell it when it should be raised, pre- or post-operation. It’s not passed in the function signature, as the implication is “You (plugin author) raised the callback, so you should know how to treat it”.


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

#4 2017-10-19 12:54:15

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: [Solved] Get callback related variables

Bloke wrote #307459:

Yeah, ‘pre’ is used when setting up the register_callback to tell it when it should be raised, pre- or post-operation. It’s not passed in the function signature […]

It makes sense but I didn’t realize before, thanks for the explanation.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

Board footer

Powered by FluxBB