[pmwiki-users] InterMap with two or more variables?

Petko Yotov 5ko at 5ko.fr
Wed Apr 30 01:41:36 PDT 2025


On 29/04/2025 22:01, Martin Cuno wrote:
> Hi all, With InterMap, I can get links by passing a variable (in the
> middle of the link string):
> https://www.pmwiki.org/wiki/PmWiki/InterMap#toc-5 My question: Is it
> also possible to have two (or more) variables?

It may be possible to configure other variables in the InterMap 
definition, but it would not be practical to change the variables to 
different values in a page.


> I would like to have links with text search, in the format:
> https://de.wikipedia.org/wiki/Hamburg#:~:text=Stauwerk%20Geesthacht.
> Here, $1=Hamburg, $2=Stauwerk%20Geesthacht. There are also other
> possible applications. Thanks and regards! Martin Cuno, Siegen,
> Germany

A markup expression for a Text Fragment may be easiest to define and use 
in a page:

   [[DeWiki:Hamburg{(txfrag "Stauwerk Geesthacht")} | click here]]

Here is a function that implements most of the standard from:
   
https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Fragment/Text_fragments

   $MarkupExpr['txfrag'] = 'ME_TextFragment($args)';
   function ME_TextFragment($args) {
     foreach($args as $search) {
       $encoded = implode(",", array_map("rawurlencode", explode(",", 
$search)));
       $out[] = "text=$encoded";
     }
     return "#:~:" . implode('&', $out);
   }


In the page, use this:

   {(txfrag "Highlight this text in the page")}
   {(txfrag "Start text,End text")} highlight between 2 texts
   {(txfrag "Term 1" "Other Term")} highlight separate terms
   {(txfrag "prefix-,term to find,-suffix")} see reference

Use quotes if you have spaces in the search terms.

It should also work with other URLs, not InterMap.

Petko



More information about the pmwiki-users mailing list