Oh, InterMap definitions are processed even before any markup rules, so
your markup rule has not been able to set the PageVariable.
Using a markup rule is not a great way to set a PageVariable. I'd use a
$FmtPV function instead. See/check how other PageVariables are defined
as functions in the core (pmwiki.php:123) eg $Groupspaced, $Title,
$BaseName or $PasswdRead. See how the page group, name or another
attribute is passed, and think how your variable will work for another
page like {OtherGroup.OtherPage$mymarkupvar}. It is complex and resource
intensive, but possible to RetrieveAuthPage the pagename, then to look
for your markup in the $page['text'] entry.
Or, piggyback on an existing PageVariable if it is never used, eg.
(:keywords:) or (:description:), and have your markup to set this
variable by a simple replacement:
# Convert (:mymarkup:) to (:keywords ccox:myvariable:).
# When a page is saved, "ccox:myvariable" will be in
# the 'keywords' property and in $page["keywords"]
Markup('mymarkupvar', '<keywords', '/\\(:mymarkup:\\)/', '(:keywords
ccox:myvariable:)');
# a better way to set the PageVariable
$FmtPV['$mymarkupvar'] = 'CCGetVariable(@$page["keywords"])';
function CCGetVariable($keywords) {
if(preg_match('/ccox:myvariable/i', $keywords)) return 'hello';
}
This will also populate the "meta keywords" tag in the HTML source of
the page with "ccox:myvariable". If this is unacceptable, select a
different way (see/copy how the keywords property is set in
stdmarkup.php, and add an entry to $SaveProperties).
Petko
---
Change log : http://www.pmwiki.org/wiki/PmWiki/ChangeLog
Release notes : http://www.pmwiki.org/wiki/PmWiki/ReleaseNotes
If you upgrade : http://www.pmwiki.org/wiki/PmWiki/Upgrades
On 2017-07-14 20:45, Christopher Cox wrote:
Let's say I now want to use a InterMap on such a page with my page
variable populated via markup...
such that I want to have
myintermap: http://example.com/$1?a={$mymarkupvar}
The variable doesn't populate in that one. Is it possible?
On 07/14/2017 01:15 PM, Christopher Cox wrote:
Bingo! Thanks Petko! '<{$var}'
On 07/14/2017 12:59 PM, Petko Yotov wrote:
When the markup rules are processed one after another, PageVariables
like {$mymarkupvar} are replaced with their contents very early. Most
other markup rules are processed later, see
pmwiki.php?action=ruleset. So your page variable is not yet set when
it is encountered in the page, and it is replaced with nothing, empty
string.
MarkupMarkup, ie (:markup:) rules are processed before most other
rules, and before PageVariables. The content of a (:markup:) block is
passed through all markup rules one after another, like for the page,
but before the page. At that point, if you encounter your markup
rule, it will set the page variable (but not display it in the same
block). However, later, when the rest of the page is processed, the
page variable value is already set so when your markup is
encountered, the variable is replaced with the value.
If you must process your markup rule before {$PageVariables}, change
the "when" argument (second) on the Markup() call.
Petko
---
On 2017-07-14 19:45, Christopher Cox wrote:
Ok.. this is weird. If my (:mymarkup:) is embedded in
(:markup:)(:markupend:) it works and my page variable is set. What
am
I missing?
On 07/14/2017 11:45 AM, Christopher Cox wrote:
What I want is to have something like:
(:mymarkup:)
{$mymarkupvar}
on a page. Where mymarkup does inside it's function:
global $FmtPV;
$GLOBALS['myvar'] = 'hello';
$FmtPV['$mymarkupvar'] = '$GLOBALS["myvar"]';
_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users