Jump to content

hook for InputfieldFile::processInputAddFile not working?


zyON
 Share

Recommended Posts

I'm trying (slowly) to build my first PW Module, mostly to learn how everything works internally with the API. 

I'm trying to attach a function with a hook to grab the event of adding a new file to a page but I'm can't seem to fire it (I'm talking about adding a new file via de admin interface).

I've declared the hook in the init() fuction of the module as: 

$this->addHook('InputfieldFile::fileAdded', $this, 'addFile');

and my function looks like this:

public function addFile($event){
$file = $event->arguments(0);
$this->message("You Added a file: {$file->name}."); 
}

The message is never displayed.

I've tried with InputfieldFile::processInputDeleteFile and it works.

Also I've tried with InputfieldFile::processInputDeleteFile but it doesn't seem to work either.

I'm using PW 2.4.0. 

Any ideas? Thanks.

Link to comment
Share on other sites

Apeisa, 

Thanks, you're right. I've used: 

public function addFile($event){
$file = $event->arguments(0);
$this->message("You Added a file: {$file->name}.", Notice::log); 
}

and the file name is logged in the messages.txt file. 

It's the first time I've used the log and I had to search inside the PW files on how to use it. I guess when you wrote "Try writing $log instead of message" you are referring to the same thing but I guess there's a way using the $log variable? 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...