How to disable pmwiki-utils.js script tag from a local PHP page?

Is there a maintainable way to disable adding the script tag for pmwiki-util.js in HTMLFooter? I would like to disable such script tag in a few local/Group.Page.php files while generally keeping it enabled for all other pages in local/config.php.

File scripts/stdmarkup.php adds pmwiki-utils.js based on a fairly long conditional expression. Consequently, to disable the script tag from a local PHP page, without prior knowledge of which core features are enabled, I should set:

$PmTOC['Enable'] = $PmEmbed = $EnableSortable = $EnableHighlight = $ToggleNextSelector = 0;

That works but it isn't easily maintainable; I worry that, on a future pmwiki version upgrade, I could forget to check if the conditional expression in stdmarkup.php has changed and change Group.Page.php accordingly. Is there, or could it be added, a better alternative to the above code? Thank you. SteP November 08, 2020, at 01:31 PM

Add the following in Group.Page.php: --Petko November 08, 2020, at 01:38 PM

  function DisablePmUtils(){
    global  $HTMLFooterFmt; 
    $HTMLFooterFmt['pmwiki-utils'] = '';
  $PostConfig['DisablePmUtils'] = 900;

Thank you, Petko, it works well. SteP November 08, 2020, at 09:25 PM

From PmWiki 2.3.2, the utility library will be included in the header, not footer, and there is a new variable that makes it simpler to disable it. Use $EnablePmUtils = 0; in config.php instead of the above function. --Petko

Does $EnablePmUtils = 0; need to be inside config.php or can it be inside a local PHP page instead? SteP

This is a PHP variable, it needs to be in a PHP file, either pmwiki/local/farmconfig.php for a WikiFarm, or local/config.php for the one full wiki, or local/Group.php for a group, or local/Group.Page.php for one page only. --Petko

Problem with class names "hide" and "show".

Classes names "hide" and "show" are conflicting with popular frameworks (Bootstrap as example), so TOC does not work as expected. Is it possible to change names to something more individual like "PmTOC-hide" and "PmTOC-show" for example? Or make it possible to change class names from config.php.

Finar February 24, 2020, at 11:05 AM

Added to Subversion for the next version. --Petko February 24, 2020, at 12:53 PM

With MinNumber = -1

The feature description says:

$PmTOC['MinNumber'] = -1; # the TOC will not be automatic, only the (:toc:) directive will create a table of contents in the page.

but for a page without (:toc:) and with one level-2 heading I get the TOC.

The key line is pmwiki-utils.js line 156

var shouldmaketoc = ( !tocdiv && toc_headings.length < dtoc.MinNumber && dtoc.MinNumber != -1) ? 0:1;

Here's some console log for this page

pmwiki-utils.js:157     tocdiv: null
pmwiki-utils.js:158     !tocdiv: true, length: 1, MinNumber: -1
pmwiki-utils.js:159     shouldmaketoc: 1

Shouldn't shouldmaketoc be set to 0 for this page?

In config.php I have:

$PmTOC['Enable'] = 1;
$PmTOC['MinNumber'] = -1;
$PmTOC['MaxLevel'] = 3;
$PmTOC['EnableBacklinks'] = 1;

Thank you --SteP February 01, 2020, at 05:45 PM

Good catch, I'm releasing 2.2.126 now. I am deprecating MinNumber = -1 (which should work for a while), but from now on use MinNumber = 9999 or larger to suppress the automatic TOC (documentation updated). --Petko February 01, 2020, at 07:09 PM

Thank you for fixing this issue and for the new release: downloaded, tested, I can confirm it works for me. --SteP February 01, 2020, at 07:29 PM

This is a talk page for improving PmWiki.TableOfContents.