<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>My problem is that what I want to set is a bit expensive
(involves some external web services). So I was looking for a way
to set it only if a piece of markup was done on a page. I'd like
to leave in the user's hands rather than hardcode exceptions or
limit to specific groups or pages.</p>
<p>Thanks for all the tips and info on this though!</p>
<p>My original thought was to use some new markup rather than the
InterMap, I may still pursue that route. Ultimately, I may create
my own InterMap like thing that takes this and formats for the
full URL with my PageVariable in it.... I still want the
PageVariable for cases outside of this.<br>
</p>
<p><code><br>
</code></p>
<p><code>workspace://SpacesStore/a4757c91-8291-4b2f-9e6c-bff38fbed25b</code></p>
<br>
<div class="moz-cite-prefix">On 07/14/2017 03:09 PM, Petko Yotov
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:7434ce509ebcf950f26d755ab5a1386d@5ko.fr">Oh, InterMap
definitions are processed even before any markup rules, so your
markup rule has not been able to set the PageVariable.
<br>
<br>
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.
<br>
<br>
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:
<br>
<br>
# Convert (:mymarkup:) to (:keywords ccox:myvariable:).
<br>
# When a page is saved, "ccox:myvariable" will be in
<br>
# the 'keywords' property and in $page["keywords"]
<br>
Markup('mymarkupvar', '<keywords', '/\\(:mymarkup:\\)/',
'(:keywords ccox:myvariable:)');
<br>
<br>
# a better way to set the PageVariable
<br>
$FmtPV['$mymarkupvar'] = 'CCGetVariable(@$page["keywords"])';
<br>
<br>
function CCGetVariable($keywords) {
<br>
if(preg_match('/ccox:myvariable/i', $keywords)) return
'hello';
<br>
}
<br>
<br>
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).
<br>
<br>
Petko
<br>
<br>
---
<br>
Change log : <a class="moz-txt-link-freetext" href="http://www.pmwiki.org/wiki/PmWiki/ChangeLog">http://www.pmwiki.org/wiki/PmWiki/ChangeLog</a>
<br>
Release notes : <a class="moz-txt-link-freetext" href="http://www.pmwiki.org/wiki/PmWiki/ReleaseNotes">http://www.pmwiki.org/wiki/PmWiki/ReleaseNotes</a>
<br>
If you upgrade : <a class="moz-txt-link-freetext" href="http://www.pmwiki.org/wiki/PmWiki/Upgrades">http://www.pmwiki.org/wiki/PmWiki/Upgrades</a>
<br>
<br>
<br>
On 2017-07-14 20:45, Christopher Cox wrote:
<br>
<blockquote type="cite">Let's say I now want to use a InterMap on
such a page with my page
<br>
variable populated via markup...
<br>
<br>
such that I want to have
<br>
<br>
myintermap: <a class="moz-txt-link-freetext" href="http://example.com/$1?a=">http://example.com/$1?a=</a>{$mymarkupvar}
<br>
<br>
<br>
The variable doesn't populate in that one. Is it possible?
<br>
<br>
<br>
On 07/14/2017 01:15 PM, Christopher Cox wrote:
<br>
<blockquote type="cite">Bingo! Thanks Petko! '<{$var}'
<br>
<br>
<br>
On 07/14/2017 12:59 PM, Petko Yotov wrote:
<br>
<blockquote type="cite">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.
<br>
<br>
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.
<br>
<br>
If you must process your markup rule before
{$PageVariables}, change the "when" argument (second) on the
Markup() call.
<br>
<br>
Petko
<br>
<br>
---
<br>
<br>
On 2017-07-14 19:45, Christopher Cox wrote:
<br>
<blockquote type="cite">Ok.. this is weird. If my
(:mymarkup:) is embedded in
<br>
(:markup:)(:markupend:) it works and my page variable is
set. What am
<br>
I missing?
<br>
<br>
<br>
On 07/14/2017 11:45 AM, Christopher Cox wrote:
<br>
<blockquote type="cite">What I want is to have something
like:
<br>
<br>
<br>
(:mymarkup:)
<br>
<br>
{$mymarkupvar}
<br>
<br>
<br>
on a page. Where mymarkup does inside it's function:
<br>
<br>
<br>
global $FmtPV;
<br>
<br>
<br>
$GLOBALS['myvar'] = 'hello';
<br>
<br>
$FmtPV['$mymarkupvar'] = '$GLOBALS["myvar"]';
<br>
<br>
<br>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<br>
_______________________________________________
<br>
pmwiki-users mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:pmwiki-users@pmichaud.com">pmwiki-users@pmichaud.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://www.pmichaud.com/mailman/listinfo/pmwiki-users">http://www.pmichaud.com/mailman/listinfo/pmwiki-users</a>
<br>
<br>
</blockquote>
<br>
</body>
</html>