[pmwiki-users] FmtPageList undefined

adam overton a at plus1plus1plus.org
Tue Jul 21 04:59:12 CDT 2009

hi hans
thanks for the response

here's what i'm trying to do:
i'm in the process of putting together some simple code to send  
automatic updates to Twitter (that part already works).
the plan is to set up a cron job (once-a-day) that calls something like:

the function for 'action=postToTwitter' will look to see which pages  
(in a certain set of groups) have a creation dates ($page["ctime"])  
within the last 24 hours.

my plan was to use your powertools pagelist function to spit out a  
comma-separated list of the pages that meet this specification. i was  
testing to make sure it would work by using a PV executing powertools  
- it looks like this:

$FmtPV['$tweettest'] = 'MxPageList($pn, "list=nocoregroups if=\"date  
'.strftime('%Y%m%d%H%M', strtotime('-24 hours')).'.. {=\ 
# {=$PageCreationDateYMDHS} simply gathers $page["ctime"]

this spits out exactly what i need...  
group1.newpage1,group1.newpage2,group2.newpage1 ... but the problem  
is it only spits it out to the page/screen. that was sufficient for  
the test. the next step i was hoping to accomplish was to instead  
redirect the output of MxPageList as a string to a function, i.e.:

$HandleActions['postToTwitter'] = 'postToTwitter';
function postToTwitter($pagename, $auth) {
	$mxpagelistOutput = MxPageList($pagename, "list=nocoregroups if= 
\"date ".strftime('%Y%m%d%H%M',
		strtotime('-24 hours')).".. {=\$PageCreationDateYMDHS}\"");
	foreach(explode(",",$mxpagelistOutput) as $pn) {
		$twitterMessage = "Yay! a new page was added today! ".PageVar 

the wall i'm hitting is that i don't seem to know how to grab hold of  
the MxPageList (or FmtPageList) output. i figured it was spitting out  
a string, but apparently it's not, because it spits out some odd  
binary gibberish, something like "??3P??". either that or the {=\ 
$PageCreationDateYMDHS} PV is getting chewed up. i think it's the  
former issue, though, because the problem persists even when i  
simplify the pagelist args to "group=Test".

note that i've also tried the same operations by substituting what i  
think is appropriate FmtPageList code above (at least it's the  
FmtPageList code i saw in PowerTools, and copied&pasted it), with the  
same gibberish result.

i wonder if this makes sense now what i'm trying to accomplish?
do you or patrick see a way to get the output of MxPageList or  
FmtPageList? is there something i'm not understanding?

many many thanks for your help!

On 21 Jul 2009, at 12:26 AM, Hans wrote:

> Tuesday, July 21, 2009, 12:26:48 AM, adam overton wrote:
>>  # i've tried loading both pagelist.php and stdconfig.php
>> beforehand (one and then the other)
>>  //include_once('scripts/pagelist.php');
>>  include_once('scripts/stdconfig.php');
>>  $argsx = "group=Test";
>>  $optx = array('o' => $argsx, 'fmt' => 'csv');
>>  $pagelistTest = FmtPageList('$MatchList', $pagename, $optx, 0);
>>  # or using the PowerTools pagelist function:
>>  //$pagelistTest = MxPageList($pagename, "group=Test");
>>  echo $pagelistTest;
>> this all at the very very bottom of config.php beneath everything  
>> as suggested.
>> and, something like the following still works fine, running at the  
>> same time:
>>  $FmtPV['$blamtest'] = 'MxPageList($pn, "group=Test")'; # works
>> perfect, show a csv-list of pages in the group 'Test'
> Adam, i am puzzled to understand what you are trying to achieve.
> To put the code above in config.php makes no sense to me.
> Regards powertools.php functions: they are designed to work with the
> powertools markup expressions, and those markup expressions use the
> standard PmWiki approach for creating new expressions, and of course
> the standard syntax in a page.
> Above you seem to be trying to create a formatted pagelist output
> using a page variable. I would think this could be problematic, and
> using a markup expression would be better.
> Regards the powertools markup expression (MX) {(pagelist ...)}:
> The output format is limited, and one cannot use fmt= options in the
> expression. Specifically it was not designed to use pagelist
> templates, as i did not know how to do that. Any modifications to the
> code needs to be done in the helper function FPLSimpleText.
> But without knowing what you try to achieve it is not possible to
> give any hints on this.
>   ~Hans

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20090721/cf7da664/attachment-0001.html 

More information about the pmwiki-users mailing list