[pmwiki-users] Search for several words with OR operator

Petko Yotov 5ko at 5ko.fr
Thu Jun 29 01:49:28 PDT 2023


On 29/06/2023 10:02, Gregor Klarič wrote:
> I am trying to find all pages which contain word1 OR word2 OR word3
> 
> Is this possible?

Not exactly out of the box, but in a custom function you can do this:

   $list = [];

   $opt = [''=>['word1'] ];
   FPLTemplatePageList($pagename, $list, $opt);

   $opt = [''=>['word2'] ];
   FPLTemplatePageList($pagename, $list, $opt);

   $opt = [''=>['word3'] ];
   FPLTemplatePageList($pagename, $list, $opt);

   # now $list has all pages that contain word1 OR word2 OR word3


Out of the box something similar can be achieved with categories:

   https://www.pmwiki.org/wiki/PmWiki/Categories

Pages can belong to multiple categories and can be shown with Pagelists 
in very flexible ways, for example:

   !! All pages from Cat1 OR Cat2 (at least one)
   (:pagelist category=Cat1,Cat2:)

   !! All pages from Cat1 AND Cat2 (both)
   (:pagelist category=+Cat1,+Cat2:)

See https://www.pmwiki.org/wiki/PmWiki/PageLists#wildcards

And you can format the list with a custom pagelist template if you want.

Petko



More information about the pmwiki-users mailing list