You can see an example of what's coming here:
https://www.chalut-greenservice.ch/modules/oledrion/
I don't know when they will submit their updates to GitHub, but it looks very promising!
// Assume you have TreeObj (XoopsObject) and TreeHandler (XoopsPersistableObjectHandler)
$treeHandler = xoops_getModuleHandler('tree', 'your_module'); // Replace 'your_module' with your actual module name
$criteria = new CriteriaCompo();
// Fetch data from the 'tree' table
$treeObjects = $treeHandler->getObjects($criteria);
// Create XoopsObjectTree
$tree = new XoopsObjectTree($treeObjects, 'cid', 'pid', null);
// Generate the HTML dropdown options
$options = $tree->makeSelectElement('pid', 'name', '--', '-');
// Create the $selectElement = '. $options . '';
echo $selectElement;
class CustomObject extends stdClass {
public function getVar($var, $format = 's') {
// Implement the getVar method as needed for your data
// You can fetch the value of the property based on the $var parameter
// and apply any formatting if required.
// For example:
switch ($var) {
case 'cid':
return $this->cid;
case 'pid':
return $this->pid;
// Add more cases as needed for other properties
default:
return null; // Return null for unknown properties
}
}
}
// Create an array of CustomObject instances
$customObjects = array();
// Populate the $customObjects array with your data (stdClass objects)
// For example:
$stdObject = new stdClass();
$stdObject->cid = 1;
$stdObject->pid = 0;
// Add other properties as needed
$customObject = new CustomObject();
$customObject->cid = $stdObject->cid;
$customObject->pid = $stdObject->pid;
// Add other properties and implement getVar for CustomObject as needed
$customObjects[] = $customObject;
// Create the XoopsObjectTree using CustomObject instances
$tree = new XoopsObjectTree($customObjects, 'cid', 'pid', null);