Jump to content

Find page name when deleting it permanently from trash


Recommended Posts

I need to get the name of a page at the moment when it is permanently removed from the Trash. 

I need this because I have to do some cleanup for files associated with it that I'm uploading to Amazon S3 with a module I'm trying to develop.

Now, for example, it I use the following hook: 

$this->addHook('Pagefiles::delete', $this, 'deleteStuff');

I can get the name of the file being deleted, the field it belongs to but when I try to get the page name I get a different name like this: "pageid_pagename" not the original page name. 

public function deleteStuff($event){
$file = $event->arguments(0); 
$filename = $file->name; // filename OK
$field = $file->field->name; // field name OK
$page = $file->page->name // Not what I was looking for


The page name is changed when the page is moved to the Trash. Any ideas on how can I get the clean name (without parsing this new string)?

Link to comment
Share on other sites

You would use a after Page::deleteReady hook to fetch the page that's going to be deleted.

This hook is called when page is deletable and actually WILL get deleted right after. 

$this->addHook("Class:method", $this, "someMethod");

is to add a new method to a class with a hook.

You would give it addHookAfter or addHookBefore.

  • Like 2
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

  • Recently Browsing   0 members

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