[pmwiki-devel] page text variables across groups with Attach:

John Rankin john.rankin at affinity.co.nz
Fri Dec 17 12:43:50 CST 2010


> On Wed, Dec 15, 2010 at 11:45 PM, John Rankin
> <john.rankin at affinity.co.nz> wrote:
>> I don't see an easy way to tell pmwiki to retrieve the "graphic" PTV as
>> Attach:GroupA/an-image.png instead of just Attach:an-image.png
>
> [1]This code adapted from stdmarkup.php, '{$:var}' rule, to do ptv
> substitution:
>
>  $foo = '{$:test}';
>  $foo = preg_replace('/\\{(\\*|!?[-\\w.\\/\\x80-\\xff]*)(\\$:?\\w+)\\}/e',
>  "PRR(PVSE(PageVar(\$pagename, '$2', '$1')))", $foo);
>

Thanks, Peter, that was the trick, giving:

  $g = FmtPageName('$Group./', $page);
  $ptv = trim(PVSE(PageVar($pagename, '$:graphics', $page)));
  $ptv = preg_replace('!(Attach:)([^/]+)$!','$1'.$g.'$2',$ptv);

Example: http://www.wikipublisher.org/wiki/Cookbook/BookMetadata

-- 
John Rankin




More information about the pmwiki-devel mailing list