pages.select

Select pages that match given criteria
argument keys:(if not stated otherwise, possible values documented in ListPages module):

  • site: site to get pages from, e.g. "my-site"
  • pagetype (optional): default "*"
  • categories (optional): list of category names to pull pages from, default: all categories
  • tags_any (optional): list of tags, page must have at least one of them
  • tags_all (optional): list of tags, page must have all of them
  • tags_none (optional): list of tags, page must have none of them
  • parent (optional): single page name or "-" for pages with no parent
  • created_by (optional): single user name
  • rating (optional)
  • order (optional)

returns: returns: list of page full names

This pages.select demo uses the sample code below. Create a separate file in your hosted site. Change the path to the wikidot_class.inc and xmlrpc.inc files. Set only the criteria needed to perform the select. Replace the all caps USERNAME, API KEY, and SITENAME with values specific to you and your site.


Sample Code

<?php
//set globals before includes
    $newdebuglevel = 0;    
 
//add includes
//change path to your server location
    include("../classes/wikidot_class.inc");
 
//set startup parameters for xmlrpc
//change path to your server location
    require_once("../classes/xmlrpc.inc");
    $GLOBALS ['xmlrpc_null_extension' ] = true;
    $ServerPath = "xml-rpc-api.php";
    $ServerHostName = "www.wikidot.com";
    $ServerPort = "";
 
//create a client for your site
 
    $Client = new xmlrpc_client($ServerPath,$ServerHostName,$ServerPort);
    $Client->setCredentials("USERNAME","API KEY");
    $Client->setDebug($newdebuglevel);
    $Client->setSSLVerifyPeer(false);
    $Client->setSSLVerifyHost(false);
    $Client->return_type = "phpvals"; //forces return of page.get_one as php values
    $SiteName = "SITENAME";
 
////////////test code
////////////code doesn't include error checking
    $pageobj = new WikidotPage($SiteName, $Client);
    $returnarray = array();
    echo "<h3>pages.select</h3></br><hr>";
//uncomment only the values needed, extra values or empty values cause errors
    $criteria = array();
    $criteria['pagetype'] = "*"; //"*", "normal", "hidden"
    $categories = array("CATEGORY1", "CATEGORY2");  
    $criteria['categories'] = $categories;
//    $ytags = array(""); //any "-", "=", "==", list "tag" OR, "+tag" AND, "-tag" AND NOT
//    $criteria['tags_any'] = $ytags;
//    $atags = array(""); //all
//    $criteria['tags_all'] = $atags;
//    $ntags = array("_hide", "_hidden"); //none
//    $criteria['tags_none'] = $ntags;
//    $criteria['parent'] = ""; //"-", "=", "-=", ".", "parentname"
//    $criteria['created_at'] = "";
//    $criteria['created_by'] = "";
//    $criteria['rating'] = ""; //"n", "=", ">", "<", "<=", ">=", "<>"
    $criteria['order'] = "title";    
//    $criteria['link_to'] = "";     
//    $criteria['offset'] = ""; //"n"
//    $criteria['range'] = ""; //".", "before", "after", "others"
//    $criteria['datafield'] = array("fieldname", "fieldvalue");
    $pageobj->php_pages_select($criteria, $returnarray);
    foreach($returnarray as $page){
        echo "Site: ".$pageobj->getSite()."=> ".$page."</br>";}
?>

Download Code File

Live demo

Uses above code in an Iframe from a PHP host.


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