PageListMultiTargets

Summary: Enable multiple pages and wildcards in PageList
Version: 20151222
Prerequisites:
Status: Experimental
Maintainer: Petko
Categories: PageList, Links, PHP55, PHP72
Users: +2 (view / edit)
License: GPL3+

A feature similar to this was added to PmWiki 2.3.0.

If you previously used this recipe, please disable it when you upgrade (your directives and templates should work like before, probably faster). See documentation at PmWiki.PageLists#pagelistlink, a discussion at PITS:01475, and this message at the mailing list about performance.

Description

The recipe enables multiple pages and wildcards by adding a links= option to the pagelist directive.

The recipe provides complex searches/pagelists for categories and backlinks.

Installation for PmWiki 2.2.145 or older

Copy the file pagelistmultitargets.phpΔ (alt.download pagelistmultitargets.php) to your pmwiki/cookbook directory. Then add the following line to config.php:

  include_once("$FarmD/cookbook/pagelistmultitargets.php");

Usage

In a wiki page use the new links= parameter, instead of the link= parameter, for multiple pages or wildcard lists.

  • Use a comma between multiple targets.
  • Use '+' or '-' to force or exclude targets
    • If a target is preceded by '-' (minus), that target is excluded, so the pagelist will exclude all pages linked to that target.
    • If a target is preceded by '+' (plus), that target is required.
    • If some targets are not preceded by '+' or '-', then the pagelist will contain pages linked to at least one of these targets.
  • You can use wildcards in the target names, with '*' meaning 'anything', for example "*.HomePage" or "Site.*".

Of course, you can use any other pagelist parameters like name, group, count, fmt, etc.

Examples

(:pagelist links=PmWiki.DocumentationIndex,PmWiki.BasicEditing:) will list pages linked to at least one among PmWiki.DocumentationIndex and PmWiki.BasicEditing.

(:pagelist links=+PmWiki.DocumentationIndex,+PmWiki.BasicEditing:) will list pages linked to BOTH page PmWiki.DocumentationIndex and PmWiki.BasicEditing.

(:pagelist links=PmWiki.DocumentationIndex,-PmWiki.BasicEditing:) will list pages linked to PmWiki.DocumentationIndex and NOT linked to PmWiki.BasicEditing.

(:pagelist links=-Category.*:) will list any pages that don't link to a page in the Category group.

(:pagelist links=Category.*,-Category.Category:) will list any pages that link to a page in the Category group, except those linked to Category.Category.

Configuration

The recipe can "hijack" the original link= parameter in PageLists, allowing multiple targets with link= too. To enable this feature, add to config.php such a line:

  $EnablePLMTLink = 1;

Notes

  • If you need pages linked to a single target, using the core parameter "link=" will be slightly faster.
  • The following are currently equivalent: links=PagenameWithoutGroup and links=*.PagenameWithoutGroup (this may change in the future, don't rely on it.).

Change log / Release notes

  • 20151222 Fix bug with $EnablePLMTLink.
  • 20140312 Add $EnablePLMTLink.
  • 20130415 Small logic/speed optimization; reindex pages that appear out of date in the .pageindex file.
  • 20130414 First public release, ready to be tested.

See also

Contributors

  • Recipe written and maintained by Petko (5ko [snail] 5ko [period] fr) based on code from pagelist.php by Pm.
  • If this recipe helps you or saves you time, you can help support its continued development by .

Comments

See discussion at PageListMultiTargets-Talk

User notes +2: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.