[pmwiki-users] How can I properly adjust the sequence of my own markups

1 2 vanship85 at gmail.com
Fri Aug 11 11:34:37 CDT 2006


Hi

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 ?

Thank you

For example, I want to add a new page property "Price", in the form of

Price = 3.56

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

Markup(Price , '>&',
  "/\\(:Price ?\\s+(.+?)\\s*:\\)/ei",
  "PZZ(PCache($pagename,
     array(Price => SetProperty(\$pagename, Price , PSS('$1')))))");
$SaveProperties[] = "Price" ;

These codes successfuly indeed save a new property Price in the page file if
I provides
(:Price 3.56:)
in the source of the page.

But When I try to use a new markup
(:DisplayPrice:)
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

Markup(DisplayPrice, '>if',
  "/\\(:DisplayPrice\\s*:\\)/ei",
  "DisplayPrice(\$pagename)");

function DisplayPrice($pagename)
{

 global $PCache;

 if (!isset($PCache[$pagename]))
 {
  $dp_page = RetrieveAuthPage($pagename, 'read', false, READPAGE_CURRENT);
 }
 else
 {
  $dp_page = &$PCache[$pagename];
 }
  if (!$dp_page) return "Sorry, cannot read the page";

  return "Price is ".$dp_page["Price"];
}

Here will come the problem. Suppose some parts of the begining Test.Testpage are

(:Price 3.1:)

(:DisplayPrice:)

It will display

Price is 3.1

When I edit Test.Test page, change the lines as

(:Price 3.5:)

(:DisplayPrice:)

and press preview button, I will still see the old value as

Price is 3.1

But when I save it and view the page, it will change to the new value as

Price is 3.5



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.

Thank you for reading so many words :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-users/attachments/20060812/911863c3/attachment.html 


More information about the pmwiki-users mailing list