<div>Hi</div>
<div> </div>
<div>Currently, I want to add some functions in the pmwiki. The aim is that I set a new page property and want to display them all through new defined markups. But I can not properly adjust the sequence of these properties and therefore in preview mode, the display markup receive the old value of the page property and show the old value. Can anyone explain detailed about the sequence of the markup and the use of the second parameter of Markup function ?
</div>
<div> </div>
<div>Thank you</div>
<div> </div>
<div>For example, I want to add a new page property "Price", in the form of</div>
<div> </div>
<div>Price = 3.56</div>
<div> </div>
<div>in a saved page in wiki.d directory. To implement it, I use Markup function to add a new description of markup (:Price XXX:) and add "Price" into the $SaveProperties to make pmwiki save this property to the page file. So I add these lines in the code
</div>
<div> </div>
<div>Markup(Price , '>&', <br> "/\\(:Price ?\\s+(.+?)\\s*:\\)/ei",<br> "PZZ(PCache($pagename, <br> array(Price => SetProperty(\$pagename, Price , PSS('$1')))))"); <br>$SaveProperties[] = "Price" ;
</div>
<div> </div>
<div>These codes successfuly indeed save a new property Price in the page file if I provides </div>
<div>(:Price 3.56:)</div>
<div>in the source of the page.</div>
<div> </div>
<div>But When I try to use a new markup</div>
<div>(:DisplayPrice:)</div>
<div>to show the value of the Price. I also add the description of this markup by Markup function and specify a new function of replacement to load the value of the price property. Thus I write</div>
<div> </div>
<div>Markup(DisplayPrice, '>if',<br> "/\\(:DisplayPrice\\s*:\\)/ei",<br> "DisplayPrice(\$pagename)");</div>
<div>
<p>function DisplayPrice($pagename)<br>{<br> <br> global $PCache;<br> <br> if (!isset($PCache[$pagename]))<br> { <br> $dp_page = RetrieveAuthPage($pagename, 'read', false, READPAGE_CURRENT);<br> }<br> else<br> {<br> $dp_page = &$PCache[$pagename];
<br> } <br> if (!$dp_page) return "Sorry, cannot read the page";<br> <br> return "Price is ".$dp_page["Price"];<br>}<br></p>
<p>Here will come the problem. Suppose some parts of the begining Test.Test page are</p>
<p>(:Price 3.1:)</p>
<p>(:DisplayPrice:)</p>
<p>It will display</p>
<p>Price is 3.1</p>
<p>When I edit Test.Test page, change the lines as</p>
<p>(:Price 3.5:)</p>
<p>(:DisplayPrice:)</p>
<p>and press preview button, I will still see the old value as</p>
<p>Price is 3.1</p>
<p>But when I save it and view the page, it will change to the new value as</p>
<p>Price is 3.5</p>
<p> </p>
<p>So how can I change the sequence so that (:DisplayPrice:) can receive new value of (:Price:) in preview mode? The second parameter of the Markup function of (:Price:) is copied from that of (:title:) and that of (:DisplayPrice:) is copied from that of (:include:) in
stdmarkup.php.</p>
<p>Thank you for reading so many words :)</p></div>