[pmwiki-users] PAGELIST / Math / summatory

edwin marte edwin.marte at leidba.com
Thu Sep 3 15:05:36 CDT 2009


Thanks to Emeli, Hans and Peter. I am yet testing. I have to go and will
finish tomorrow. So far I have to make some test with wikish (peter),  I
liked emeli aproach but there is something is not working (I finish that
tomorrow.) and hans look aproach looks promosing but haven't tested it yet.

Thanks To all Guys. Hope I can get this running by Tomorrow.
Regards,Edwin

On Thu, Sep 3, 2009 at 4:47 PM, Hans <design5 at softflow.co.uk> wrote:

> Thursday, September 3, 2009, 3:14:12 PM, edwin marte wrote:
>
> > What I have is SomeGroup, wich have page1, page2, page3, etc. Every
> > page have a page variable let's say called DATA.
>
> > So if we have let's say:
>
> > {SomeGroup.page1$:DATA}  =10
> > {SomeGroup.page2$:DATA}  =20
> > {SomeGroup.page3$:DATA}  =15
>
> > I want to be able to build a pagelist for giving me Total:45
>
> Here is another approach, using markup expressions.
>
> Add the following to config:
>
> # sum of data ptvs listed as data= ;
> # input argument PageName or csv list of pagenames
> MarkupExpr['sumdata'] = 'MXSumDataPTVs($pagename, $args[0], $argp)';
> function MXSumDataPTVs($pagename, $list, $args) {
>   $sum = '';
>   if(!isset($args['data'])) return 'no data PTVs selected';
>   $ptvs =  explode(',',$args['data']);
>   $plist = (isset($list)) ? explode(',',$list) : array($pagename);
>   foreach($plist as $pn) {
>      $pn = MakePageName($pagename, $pn);
>      foreach ($ptvs as $d) {
>         $v = PageTextVar($pn, $d);
>         $sum += floatval($v);
>      }
>   }
>   return $sum;
> }
>
> install PowerTools to use pagelist or plist markup expressions
> http://www.pmwiki.org/wiki/Cookbook/PowerTools
>
> then use in your page something like this to show the sum
> of PTVs named ABC and XYZ
>
> {(sumdata (plist Test.Name*) data=ABC,XYZ)}
>
> You need data= as parameter for the PTVs, you can use one or several
> separated by comas.
> The first argument is a page name or csv page list, which is supplied
> in the example with markup expression (plist)
> You could use a (pagelist ...) markup expression.
> Or simply
>
> {(sumdata Page1,Page2,Page3 data=DATA)}
>
> to sum PTV 'DATA' from pages Page1, Page2 and Page3
>
> I should add the (sumdata ) expression to PowerTools i think.
>
>
>  ~Hans
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20090903/5c3df6fc/attachment.html 


More information about the pmwiki-users mailing list