Recent Forum Posts
From categories:
page 1 of 212next »

This isn't a question, but a "heads up" for those who may run into this like I and others have.

I was having problems with ListPages when trying to sort on a data form field.
It wasn't working and I couldn't figure out why until I searched the Wikidot Community Forum and found this thread (thanks Steven Heynderickx, RobElliott and michal frackowiak for sorting it out!).

It turns out that if you use the API to create or update data form pages, you have to make sure you follow strict YAML specifications or some things (like sorting) won't work as expected. Here is my ListPages code:

[[module ListPages category="empdbf" separate="no" perPage="25" order="@URL|_lastname" tags="@URL|+_active" urlAttrib="prefix1"]]
[/%%fullname%% %%form_data{firstname}%% %%form_data{lastname}%%] (%%form_data{id}%% / %%form_data{sec_num}%%)

The original PHP code built the data form fields like this:
// we use an array to store the data form field data
// this loop creates each line of the data form page content
foreach($newcontent_ar as $ky=>$dt){          //step thru array adding the field names and data
    $newcontent = $newcontent.$ky.":".$dt."\n";}
$newcontent = rtrim($newcontent);}          //removes last \n from string

The corrected PHP code is:
// we use an array to store the data form field data
// this loop creates each line of the data form page content
foreach($newcontent_ar as $ky=>$dt){          //step thru array adding the field names and data
    // Update 3/1/2013
    // Note - when formatting data form content, it is important to have a space after the colon.
    // if omitted, pages will work, but sorting via ListPages will not.
    // Strict YAML rules require the space and so does Wikidot.
    $newcontent = $newcontent.$ky.": ".$dt."\n";}
$newcontent = rtrim($newcontent);}          //removes last \n from string

Sticking that one tiny space after the colon on the second to last line was all it took. Thankfully, this code is used to regularly update my existing pages from a DBF file used by my point of sale system, so I didn't have to write a custom routine to fix pages that already existed.

I'm using PHP and the API to collect activity log file data from our restaurants and then create wiki pages to store the log files. This allows anyone with the proper permission to easily look at this data with minimal hassle.

The basic process works like this:

  • Users edit prep (lead) times for our online ordering system.
  • Their activity is written to a log file.
  • When our end of day process runs at the restaurant, I copy the log files to a Dropbox folder.
  • A scheduled task fires off a batch file that uploads all of the log files via FTP to our web server.
  • About an hour later, another scheduled task launches a web browser to run the PHP page that imports the log files for each shop and uses the API to create/update the wiki pages with the current log file contents.

It works really well! The only piece that's missing for me is a way to easily summarize just the last few entries from each log file on a single page. I'd like to use ListPages for that, but need my wish (Add support for %%content{last}%% and %%content{last-n}%%) granted to make it easy.

I will probably enhance the PHP code to make it easy to display summary data. The way the wheels turn at Wikidot, I don't hold much hope for my wish being granted anytime soon.

If anyone has the need for a similar workflow, let me know and I can provide more specifics.

Capturing Log File Data by Ed JohnsonEd Johnson, 01 Mar 2013 15:02

A client (undertaker) "sells" the possibility to do online condolences to the family of the decised. So people that visit his site can fill out a form for their friend or relative. But those people are no memebers of wikidot… and also the familie that wishes to recieve the mails is no wikidot-member.

So we want to have a pre-formatted form to fill out and if a visitor presses send the mail should be recieved by the family.

So instead of gugu'r… my client makes forms for his clients, just a field for the name, and a field for the email of the contact person of the family.

I got this working… but like I descibed… for every mail send there is a page… because I'm using dataforms and not the mail-module. In this way it is also possible to have a listpages module run on all the condolences and make a nice booklet from them… but sometimes it could be sensitive information… So it has an up and a down side.

A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.

Online condolences by Steven HeynderickxSteven Heynderickx, 26 Sep 2012 07:32

I just tested this on your site and it works well. Do you have a specific application that you are applying this to? I'd like to know what your use case is for this.

by Ed JohnsonEd Johnson, 26 Sep 2012 05:27

The good side of this is that the information send in this way is not saved. But the downside is that it only works for wikidot members…

I want also to have a solution for not members. Was thinking of creating a form that can be filled out and after saving you could jump to a script that would use the information of the form and create an email of that and send it to a certain person. In this way for every mail that is send there is also a wikidot page. And sincethere is no delete-methode for the API that is a problem. Unless off course I reset all the fields to blank and always use the same page and not create a page for every "mail"… Ok breakthrough… next project. Will appear here soon.

A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.

Only members by Steven HeynderickxSteven Heynderickx, 25 Sep 2012 22:27

Then yes, the wish would be that data form values can be used to select pages via the API.

I thought you were asking for a way to check if a particular data form field existed… which you would, at the very least, need to manually check the live templates for.

Shane Smith
Web Developer and Wikidot Community Administrator
Links: Blog, Wikimated, Editor (STE), Documentation

So this could be a very good wish, no?

And should then the API documentation not be altered? Now it states:

… argument keys (if not stated otherwise, possible values documented in ListPages module):

And the ListPages documentation states:

Argument Meaning
_<data-form-field-name> Select by a field's value in a data form

A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.

Select pages the regular way, then iterate through the list of pages and check the content of each one.

Shane Smith
Web Developer and Wikidot Community Administrator
Links: Blog, Wikimated, Editor (STE), Documentation

I am wondering is it is possible to use the to select pages with datafields containing certain values or no value.

In my experience that value can be :

  • fieldname: 'something' (a string)
  • fieldname: '' (an empty string)
  • or if the field in the _template is created after the page itself it is possible that the field is not even in the content.

So how would you formulate the selector for the request if I wish to have a list of all the pages that don't have a value for "fieldname"?

I am in the habbit of formulating my request in the following way so how should it be adjusted to fullfill my wish.

        $request = xmlrpc_encode_request("",$requestarray);

A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.

Here is the test page

In internet explorer 8 it gets an error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; BTRS5841; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET4.0C)
Timestamp: Wed, 12 Sep 2012 19:22:16 UTC

Message: Object doesn't support this property or method
Line: 51
Char: 1
Code: 0

In firefox 15.0.1, I get the broken thumbnails.

In Opera 12.02, It works as expected.

I agree that to simply add a new field, just append the content string with the new field and data. The example given was more elaborate to be used as a general use snippet. What wasn't included was also updating existing form data in addition to the new form field data.

I've reported the bug, I can confirm it's the same problem for me:

Kenneth Tsang (@jxeeno)

Re: Multifile Sample Wierdness by tsangktsangk, 12 Sep 2012 12:20

Ed if you just want to add a field, you don't need this. just append to the content string your new field and value and its done… I have a feeling that the order in which content is stored in the page-source has no relevance to the order in the fields of the _template.

However I generaly don't use the title of a page because the label (title) can not be adjusted. Also I use very much the autonumbering and setting a title via links… but at that moment I don't know what the title will be so I use "new"… which is very unuseful… So I use the API to create a title that is a combination of different fields. for example name and surname. Because the title IS important for complex listpages where you want to have something usefull to read about the parent-page, like %%parent_title%%.

A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.

All you need is here… no librarys or anything… this works for me

// Thanks to the help of Jerad Whitaker this script gets the content
// of a page with a template that uses dataforms and converts all
// the fields into an array with the field names as array keys.
// I pass along the $page (%%fullname%%) and the $site (%%site_name%%)
// via the URL

// General settings


$content = $returnarray[content]; //copies string to a new string var
$newarray = array();
$stringar = explode("\n",$content ); //split the content-string into an array of strings 
foreach($stringar as $data)
    $data_ar = explode(":", $data, 2); //split the strings into form fields and form data
    $key = $data_ar[0];
    $cont = trim(trim($data_ar[1]),"'\""); //trimming off quotes and spaces
    if($key == '' && $$cont == '') ; //skip empty strings
    else $newarray[$key] = $cont;

    function getPage($site,$page,$username,$key)                       

    $request = xmlrpc_encode_request("pages.get_one",$requestarray);          
    $context = stream_context_create(array('http' => array(                   
            'method' => "POST",                                               
            'header' => "Content-Type: text/xml",                             
            'content' => $request                                             
    $file = file_get_contents("https://".$username.":".$key.                  
    "", false, $context);                     
    $response = xmlrpc_decode($file);                                         
    if ($response && xmlrpc_is_fault($response))                              
        print("Could not get ".$page);                                                  
        trigger_error("Wikidot XML-RPC Error:                             
        $response[faultString] ($response[faultCode])");
        return ($response);                                               


There is a working example on page page1

A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.

And yes, I think I will find this very useful. On my private site for work I have 2 data form templates that each have hundreds of pages in them already. If I ever have a need to add a field to either form, this idea will make it pretty simple to update those pages.

Read/Write API access is enabled for this site for members, so if you want to create some test pages or new categories here to try some of the sample code, feel free to do so. I'll double-check permissions to make sure creating new pages won't be a problem.

that is cool… only one thing… I havent gotten around to understanding how to use the library as posted here. Im using the functions Tsangk and I made… so im gonna work out what you did and come back on this later…

But this what I was suggesting to make myself… I was wondering if any of you would find this usefull… So now you already made it… thanks… I find it usefull.

A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.

no correlation, both just text fields… the date2 however is added with tha API… SO I m not sure that in this case the page content as shown is right after an API-edit or just a save from th page by a user.

A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.

Re: Quotes in YALM by Steven HeynderickxSteven Heynderickx, 11 Sep 2012 19:31

if you have gotten to this line in the pages_get_one sample
"Commented By: ".$returnarray[commented_by]."</br>";

you can add the following code to parse the content string into an array

//here is the extra code that will take the page.get_one content,
//parse it into an array with the form fields as the keys and the form data as the array values
$char = $returnarray[content]; //copies string to a new string var
$newarray = array();
$stringar = preg_split('[\n]',$char ); //split the page.get_one string into an array of strings 
foreach($stringar as $data){ 
    $data_ar = preg_split('[:]', $data, 2); //split the strings into form fields and form data
    $key = $data_ar[0];
    $cont = $data_ar[1];
    if($key == '' && $$cont == '') ; //skip empty strings
    else $newarray[$key] = $cont;} //create newarray with form field as key and form data as value 
//insert code to add new form field data into the array here
//this code below will stitch the array back into the content for pages.save_one
    $newcontent = "";
    foreach($newarray as $ky=>$dt){//step thru array adding the field names and data
        $newcontent = $newcontent.$ky.":".$dt."\n";}
        $newcontent = rtrim($newcontent); //removes last \n from string
//use $newcontent from here to go into the php_pages_save_one call

Sounds good. If you keep teasing all of these new features and don't release an update soon, I'll be rounding up a posse to head down under and wrangle that code from you! ;)

page 1 of 212next »
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License