[pmwiki-users] extract basename

Dominique Faure dominique.faure at gmail.com
Sat Apr 12 11:37:36 CDT 2008


On Sat, Apr 12, 2008 at 4:18 PM, noskule <noskule at gmx.net> 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
>
>
>  this code works if I put it in the related page but NOT if i put it in a
>  pagelisttemplate. If I put it in a pagelist template "$IssueBaseName"
>  shows the name of the current page instead of the basename of the pages
>  processed  with pagelist.
>
>  $name = PageVar($pagename, '$Name');
>  $basename = explode('-Issue-',$name);
>  $basename = $basename[0];
>  $FmtPV['$IssueBaseName'] = "'$basename'";
>
>  Does someone see the problem?
>  thanks for any hints.
>

The Cookbook.MarkupExprPlus recipe and its reg_replace function could
be very useful in your case:

The following (:pagelist:) template would generate a list of links to
the related base pages:

[[#reg_replace]]
* [[{(reg_replace '/(\w+\.\w+)-Issue-.*/i' '$1' {=$FullName})}]]
[[#reg_replaceend]]

Hope this help,
Dominique



More information about the pmwiki-users mailing list