giterlizzi / dokuwiki-plugin-datatables

Add DataTables support to DokuWiki
GNU General Public License v2.0
10 stars 10 forks source link

Datatables does not work inside namespaces or with pagenames with the term 'wiki' in them (includes suggested fix) #75

Open johngnl opened 2 months ago

johngnl commented 2 months ago

In various implementations of DokuWiki I use this outstanding plugin. I recently discovered that the plugin didn't work in pages that I created inside a namespace called 'kesselwiki', while it worked well in other namespaces of the same DokuWiki instance.

Version info of this particular DokuWiki implementation datatables: 2023-08-31 dokuwiki: 2024-02-06a "Kaos" bootstrap3: v2024-02-06

After looking at the html source code of pages having an included, well designed datatable, I noticed that sometimes the required additional files like '.../datatables.net/js/jquery.dataTables.min.js' were not loaded. So, I decided to look at the source code.

I discovered that all pages that have an ID which includes the term 'wiki', and that contain a well formatted datatable are not rendered into a working datatable. The cause of this is this code in action.php

$excluded_pages = $this->getConf('excludedPages');

if (!empty($excluded_pages) && (bool)preg_match("/$excluded_pages/", $ID)) {
 return;
}

I had no value for 'excludedPages' in conf/local.php, so apparently the default value was in effect which was set in lib/plugins/datatables/conf/default.php. Since $conf['excludedPages'] has a default value of '(wiki)', all pages that have 'wiki' either in the namespace or name don't allow for a datatable as part of the content. And while the supposed datatable is just presented as a normal table the page rendered well, this was quite confusing at first. It took a while for me to realise that the table was well formed, so that the not-showing was not caused by the table data.

To fix the issue, I considered 3 options:

  1. "Fix" the before mentioned if statement
  2. Modify the value of 'excludedPages' through the configuration manager inside DokuWiki
  3. "Fix" the default value

I decided to do the latter, because I suspect that the original idea was to exclude all pages that are placed inside the root namespace called 'wiki', part of all standard DokuWiki implementations. So in this particular implementation I changed $conf['excludedPages'] = '(wiki)'; to $conf['excludedPages'] = '(^wiki:)';

Since $ID always seems to include the complete namespace of path and pagename, only pages that reside inside the 'wiki' root namespace are excluded. (Only then _(bool)preg_match("/$excludedpages/", $ID)) is true.)

I suggest to include my slight modification of the default value, part of a following release of this plugin.