[pmwiki-users] How to get page variable of included page in php?

Petko Yotov 5ko at 5ko.fr
Thu Oct 4 03:27:12 CDT 2012


Christopher Cox writes:
> Let's say I included MyIncludedGroup.MyIncludedPage into a page called  
> ThisGroup.ThisName.  I have some php and when it is processing  
> ThisGroup.ThisName, I can easily see that Group=ThisGroup and Name=ThisName  
> using PageVar or even FmtPageName to get at the Group and Name.. but that  
> always seems to give me the page being viewed and not the included page.
>
> Is there a way to do that?  It's like there's a way to control the context  
> somehow for markup found in the included page so that it can know where it  
> came from.
>
> I guess I want the type of {$Group} (vs. {*$Group}) behavior you have when  
> using page markup... but I want that somehow for php custom markup I've  
> written. Possible??

When a wikipage is included with (:include:) its fulltext or section text is  
just inserted in the viewed page, and PmWiki forgets that it came from a  
different page. With two ecxeptions: the markup {$SomeVariable} is rewritten  
to {OtherPage$SomeVariable} in order to retain the context and the  
difference between {$Group} and {*$Group}, and [[links]] are rewritten to  
[[OtherGroup/links]]. This is controlled by the array $QualifyPatterns, and  
you could add your own patterns if you need -- see how they are set in  
scripts/stdmarkup.php.

I don't know your recipe, but I suppose you could have something like this:

  $QualifyPatterns['/\\(:mydirective:\\)/e'] =
    '"(:mydirective $group.$name:)"';

And let your recipe deal differently with (:mydirective:) and (:mydirective  
Group.Page:).

Petko




More information about the pmwiki-users mailing list