Not logged in. · Lost password · Register
Forum: General Help and Support Development RSS
IO_WIKIPAGE_WRITE (AFTER) when page was deleted
Avatar
clh #1
Member since May 2016 · 94 posts
Group memberships: Members
Show profile · Link to this post
Subject: IO_WIKIPAGE_WRITE (AFTER) when page was deleted
I need to drive some plugin code when a user has edited a page, deleted all of its content, and saved it (thus deleting it). The code should only run after Dokuwiki has made all the appropriate changes to the namespace - e.g. removing a directory if it has become empty.

The IO_WIKIPAGE_WRITE (AFTER) hook, I found, doesn't get triggered in this situation. (Not surprisingly)

How might I detect this condition?
Avatar
LarsDW223 #2
Member since Sep 2014 · 462 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
Never used it but isn't maybe COMMON_WIKIPAGE_SAVE the event you are looking for? See https://www.dokuwiki.org/devel:events_list.
Avatar
clh #3
Member since May 2016 · 94 posts
Group memberships: Members
Show profile · Link to this post
That looks like a good bet, since it explicitly reports when a page is deleted.

I'm unable to get it to fire. It registers the event okay, but neither the before or after hook is driven.
Avatar
LarsDW223 #4
Member since Sep 2014 · 462 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
Hmm...seems to work with AFTER.

Here is a little example action plugin:

/**
 * Action part: makes the show/hide strings available in the browser
 */
class action_plugin_test extends DokuWiki_Action_Plugin {
    /**
     * Register the handle function in the controller
     *
     * @param Doku_event_handler $controller The event controller
     */
    function register(Doku_Event_Handler $controller) {
        $controller->register_hook('COMMON_WIKIPAGE_SAVE', 'AFTER', $this, 'page_saved');
    }

    function page_saved($event, $params) {
        msg('Hello World!',-1);
    }
}

It should show a red error message "Hello World!" if the event is triggered. There is one thing to mention: if you just click edit and then save (without any change), then the event will not be triggered! It will only be triggered if the page is changed AND saved!
Avatar
clh #5
Member since May 2016 · 94 posts
Group memberships: Members
Show profile · Link to this post
Good to know that it works for you (still won't work for me). I'll need to do a bit of digging to make sure everything here is up-to-date.
Avatar
turnermm (Moderator) #6
Member since Oct 2009 · 4782 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
In reply to post #4
There is one thing to mention: if you just click edit and then save (without any change), then the event will not be triggered! It will only be triggered if the page is changed AND saved!

There's no save without a change.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2020-02-17, 22:26:28 (UTC +01:00)