Recent Changes · Search:

Photos

Informatique

Bases de données

Système d’information géographique

PmWiki

edit SideBar

 

Cleanup

Re: PITS.00957?. This page is quite good for pmwiki.org, but unfortunately many examples will not work out of the box on another server - there will be no Cookbook/ or PITS/ WikiGroups. We need to refactor this page in order for it to be useful on remote servers. —Petko? July 11, 2009, at 10:40 PM

examples all fixed now simon? July 28, 2009, at 04:45 AM

Other information:

  • Pm’s post about documents use of the directive and mentions customization of the markup.
  • Pm’s post responding to a request for a in response to a request for documentation.
  • Pm’s post the release of 2.2.0 beta 2 and providing examples.
  • Pm’s post for 2.2.0
  • Lots of older posts with references to “PData” including an some extensive threads with lots of brainstorming about markup including, specifically, the WikiPaths? thread started by Martin. (wikipath recipe finally released?)

Usage notes

Lists can be separated with leading spaces (a la Site.Blocklist? or Site.InterMap)

Example:
 Sea: Tasman
  Ocean:  Southern

->"{$:Sea}"
->"{$:Ocean}"
Sea: Tasman
 Ocean:  Southern
“Tasman”
“ Southern”

Lists can have leading or trailing spaces around the page variable name

Example:
Insect : Weta
:Bird  : Kiwi
: Tree: Kauri
:  Flower : Kowhai

"{$:Insect}"
"{$:Bird}"
"{$:Tree}"
"{$:Flower}"

Insect : Weta

Bird
Kiwi
Tree
Kauri
Flower
Kowhai

“Weta” “Kiwi” “Kauri” “Kowhai”

What you can’t do

Mismatch case in the page variable name

Example:
river: Whanganui
Range: Southern Alps

->[-(lowercase)-] "{$:river}"
->[-(uppercase)-] "{$:River}"
->[-(lowercase)-] "{$:range}"
->[-(uppercase)-] "{$:Range}"

river: Whanganui Range: Southern Alps

(lowercase) “Whanganui”
(uppercase) “ ”
(lowercase) “ ”
(uppercase) “Southern Alps”

Have embedded (you really didn’t expect that did you) spaces in the page variable name

Example:
:Big bird:Moa

"{$:Big bird}" "{$:Bigbird}" 
Big bird
Moa

“{$:Big bird}” “ ”

Note that leading and trailing spaces in the page variable text are retained

Example:
:Island:       Rakiura
:Volcano:               Ngauruhoe      
                            
:Caldera:Rotorua                       
                 

"{$:Island}"
"{$:Volcano}"
"{$:Caldera}"
Island
Rakiura
Volcano
Ngauruhoe
Caldera
Rotorua

“ Rakiura” “ Ngauruhoe “ “Rotorua “

Use natural page names, ie normal page name preprocessing does not occur

Example:
-<[[PmWiki.Page text variables]]
"{PmWiki.Page text variables$:Summary}"
-<[[PmWiki.PageTextVariables]]
"{PmWiki.PageTextVariables$:Summary}"
PmWiki.Page text variables “{PmWiki.Page text variables$:Summary}”
PmWiki.PageTextVariables “Page variables automatically made available through natural or explicit page markup”

Use with conditional markup

Example
(:if name {$FullName}:)
LinkUrl: http://dilbert.com
(:else:)
LinkUrl: [[Cookbook:Quotes]]
(:ifend:)

"{$:LinkUrl}" [-{$FullName}-]

LinkUrl: http://dilbert.com

http://dilbert.comPmWiki.PageTextVariables-Talk

Can’t you? —Eemeli Aro? July 28, 2009, at 06:22 AM

LinkUrl: (:if name
{$FullName}:)http://dilbert.com(:else:)[[Cookbook:Quotes]](:ifend:)

"{$:LinkUrl}" [-{$FullName}-]

LinkUrl: http://dilbert.com

http://dilbert.comPmWiki.PageTextVariables-Talk

See more examples at Test.Ptv?

Usage in code

PageTextVar relies on the $PageTextVarPatterns variable (which can be used to extend the recognized formats for page text variables in a page). In the older 2.2.0 Beta versions of PmWiki, this variable wasn’t initialized until stdmarkup.php was run, after config.php was executed. Thus, if you needed to use page text variables inside config.php, you had to initialize it yourself. This is no longer necessary, but for those who are still running earlier versions of the beta series, here’s the value to use:

SDVA($PageTextVarPatterns, array(
  'var:' => '/^:*\\s*(\\w[-\\w]*)\\s*:[ \\t]?(.*)$/m',
  '(:var:...:)' => '/\\(: *(\\w[-\\w]*) *:(?!\\))\\s?(.*?):\\)/s'));

Questions

QHow can I get the page text variable to be evaluated only when it is declared, rather than each time it is used? For example I want to do the following, where the link refers back to the page with the included text

(:Abstract:{Programme.Abstracts$RandomSection}:)
(:include {$:Abstract} lines=4:)
->[[{$:Abstract} | more ...]]
:Quote:{Cookbook.Quotes$RandomSection}
{$:Quote}
{$:Quote}
{$:Quote}
Quote

QIs there a way to overwrite Page text variables, for including the same Template twice? E.g.:

(:parameter:value1:)
(:include TemplateThatUsesParameter:)
(:parameter:value2:)
(:include TemplateThatUsesParameter:)

See Include with PTV?, IncludeWithPTV2?

It is possible to enable PTV definition in bulleted lists by entering this line in config.php

 $PageTextVarPatterns[‘* var:’] = ‘/^(\\**\\s*(\\w[-\\w]*)\\s*:[ \\t]?)(.*)($)/m’;

Thanks to EemeliAro? (from the Mailing list).

QIs it possible to use complex searches for PTV through pagelist?

For example using regexp like this: (pagelist $MyVar=“<regexp match pattern>”)? Maybe a cookbook recipe can be provided for this? Also is there a possibility to achieve complex pagelist searches based on PTV-match conditions? For example to search for all pages where PTV1=<xxx> | PTV2!=<yyy>, or some other boolean expression… I wonder if this is something that can be cookbooked?

QIs there any possibillity to include PageTextVariables in some other MarkUp? Something like that:

(:div id={{=$Name}$:project}}_small :)
Yes. Inspect the source to see that the following works. —Eemeli Aro? July 28, 2009, at 06:29 AM
(:project:bob:)
(:div id='{$:project}_small':)
blah
(:divend:)

blah


This is a talk page for improving PmWiki.PageTextVariables.

Edit · History · Print · Recent Changes · Search · Links
Page last modified on July 28, 2009, at 01:29 PM EST