On Sun, Sep 27, 2009 at 4:23 AM, Simon <nzsk...@gmail.com> wrote: > The variable $title is calculated from the contents processed within the > ChordPro markup, > and I want to make the value held in $title available in for use outside the > ChordPro markup, eg in pagelists etc.
You'll need to carefully check the order of rule processing, then, to be certain that your ChordPro rules fire before any rules that may need to make use of the PV. At a minimum '<{$var}' but it may have to be earlier... But the more I think about this the more I think you are going to have to do one of 3 things: (1) Figure out how to cache the PV value in the actual page file as one of the attributes. (This would have to do with SetProperties() and $SaveAttributes and probably some other stuff) (in which case you *will* need to edit and save each page to get a valid value for pagelists and etc.) -or- (2) Define your FmtPV so that it will actually call a function rather than just returning a value... This function would have to calculate the value of the variable based on a pagename and any other necessary parameters. -or- (3) Go back to your original idea of creating a PTV. This requires modifying the text of the page -- you may want to look at WritePTV() in Cookbook/Toolbox to either use that function or to get ideas to write your own. If ChordPro wants to calculate this value and immediately use it (in addition to saving it in the pagetext) you may have to play around with caching the value... As I look at these 3 options they all look kind of complicated. Hopefully someone else on the list who has done this sort of thing before will have a better option for you, but those appear to me to be your options if you want to be able to use the PV in a pagelist or in a {Group.Page$PV} type of context. (OFF-TOPIC: While not a necessity (I'm quite certain PVs maintain case sensitivity) your users may find {$title} to be a little confusing as opposed to the title of the page at {$Title}. Perhaps {$SongTitle} or {$ChordTitle} or something might be clearer in the long-run.) > I have added the global declaration to my function. (in front of the lines > shown in my example). > I'm still not seeing a page variable. > Do I have to tell PmWiki to 'update and save' the page? No, there's no need to tell PmWiki to 'update & save' the page unless you choose to implement option #1 above. I assume you have your PV being displayed on the page somewhere... You may want to start with something simple, just setting $FmtPV['$mytitle'] = "'Hello, World!'"; in config.php and then move it into your recipe in the mainline and then move it into the function definition, checking each time to see if you do or do not have a valid PV. This process should narrow down where your problems are occurring. Then if it's working in your function then you can have it set to a more complicated value. (Do make sure that your Markup has '<{$var}' or before in the order parameter.) -Peter _______________________________________________ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-devel