[dokuwiki] Re: Retrieving template from plugin JavaScript

  • From: Damien Regad <dregad@xxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 27 Feb 2021 11:42:19 +0100

On 27/02/2021 09.41, Tamás Haraszti wrote:

Can you please better describe what problem you wanted to solve with
this?

Sure, thanks for responding.

This is with my "Delete Page Button" plugin [1]. It allows convenient
deletion of the current page, after requesting user confirmation with a
pop-up dialog displayed by a jQuery script hooked to the button's
"click" event.

A user reported [2] that the plugin did not work with a specific
template (Bootstrap3). After research, I realized that the template did
not generate the same markup as the default DokuWiki template, resulting
in the event not being attached to the button and the page deleted
without confirmation.

So I need to identify the template, in order to define a jQuery selector
that is compatible with its markup, which I've done by parsing DOKU_TPL

let template = DOKU_TPL.replace(/[\\/]$/, "").split(/[\\/]/).pop();

It works as far as I can tell, but as mentioned previously

Then I wondered if it would not be better to export that from
$conf['template'] into JSINFO instead, as documented here
https://www.dokuwiki.org/devel:javascript#jsinfo

Thanks
D

[1]: https://www.dokuwiki.org/plugin:deletepagebutton
[2]: https://github.com/dregad/dokuwiki-plugin-deletepagebutton/issues/4

-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: