[pmwiki-users] extract basename

noskule noskule at gmx.net
Sun Apr 13 04:59:26 CDT 2008


Patrick R. Michaud schrieb:
> On Sat, Apr 12, 2008 at 04:18:41PM +0200, noskule wrote:
>   
>> hi list
>>
>> I try to build a pagevariable that get's me the basename of a related page:
>>
>> related page: Group.Name-Issue-#
>> base page: Group.Name
>>     
>
> PmWiki has this built-in.  Simply add
>
>     $BaseNamePatterns['/-Issue-\d+$/'] = '';
>
> and then the $BaseName page variable will automatically return
> the base name of a page without any -Issue-##### suffix.
>
> Pm
>
>   
the problem that I got  cases  like  *-Issue-3-Comment-2. PmWikis 
basename function  removes alle patterns. So I changed
the code above to:

$FmtPV['$IssueBaseName'] = "StripBaseName(\$pagename,'-Issue-')";
$FmtPV['$CommentBaseName'] = "StripBaseName(\$pagename,'-Comment-')";

function StripBaseName($pagename, $pattern) {
    $basename = explode($pattern,$pagename);
    $basename = $basename[0];
  return $basename;
}


this works for :
    {$IssueBaseName{$:Title}}

but not this:
    {$IssueBaseName{$Title}}

is it possible to get the $Title value for a page in a pagelist in a way?












More information about the pmwiki-users mailing list