John Rankin writes:
> John Rankin writes:
>> On 8/01/14 12:31 PM, Petko Yotov wrote:
...
> 2. $pagename is not in the scope of the callback function,
...

Sorry, I over-simplified. In practice, the $LinkTidy array is defined once
at the start and then referenced as a global variable several times in
different places to do the actual tidying. So at the time $LinkTidy is
defined, the code may not know the $pagename. Potentially, the tidying can
apply to multiple different $pagename values as it assembles several wiki
pages into one output.

Do I use \$pagename instead?

Once again, $pagename is not automatically in the scope of the callback function. If you want to use $pagename in the callback, it must somehow get into that callback. If it does, yes, when defining the callback, use \$pagename.

One way is to pass the value of $pagename to a temporary global variable and get it inside the callback PHP code.

> Read the function PCCF(), you can define custom callback templates and
> thus write less code.

And you can see how Markup_e() and MarkupToHTML() pass the $pagename variable to all callback functions that use it.

Petko


_______________________________________________
pmwiki-users mailing list
pmwiki-users@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to