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!
Now, i remebered Xoops and am wondering is there a chance to migrate Wordpress sites to Xoops?
// 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 <select> element
$selectElement = '<select name="pid">' . $options . '</select>';
echo $selectElement;
cid pid name
1 0 aa
2 1 bb
3 2 cc
<select name="pid">
<option value="0">----</option>
<option value="1">aa</option>
<option value="2">-bb</option>
<option value="3">---cc</option>
</select>
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);
Array ( [0] => stdClass Object ( [cid] => 1 [pid] => 0 [name] => name [icon] => bi-folder-plus [weight] => 10 [update_date] => 1514736000 [cid_type] => _top [description] => description [picture] => 1.jpg [status_code] => 1 [user_ip] => 127.0.0.1 [user_id] => 1 ) )
$tree = new XoopsObjectTree($object, 'cid', 'pid', null);