[pmwiki-users] How to make a link whose text is a page text variable

Randy Brown randy at brownragfilms.com
Thu Dec 19 12:51:49 CST 2013


> Something like this may work:
> 
>  Markup('[[|~', '<[[|',
>    "/(?>\\[\\[([^|\\]]+))\\|\\s*\\~\\s*]]/e",
>    "Keep(MakeLink(\$pagename, PSS('$1'),
>      BestTitle(MakePageName(\$pagename,PSS('$1')))
>      ),'L')");
> 
>  function BestTitle ($pn) {
>    $sum = PageTextVar($pn,'Summary');
>    if (strlen($sum)) return $sum;
>    else return PageVar($pn, '$Title');
>  }

Thanks, Petko. That seems to work. 

If I don't run into problems, maybe I should post this as a recipe called "Best Title: Use A Page Text Variable For Link Text when available". However, if the "/e" only works for versions before PHP 5.5, then maybe I shouldn't. What do you think?

Randy


More information about the pmwiki-users mailing list