Hi guys,
I have a custom table created (vendor_categories), that link to users table of modx, my question is how to create a tree look menu from my hierarchical categories table?
here’s my vendor_categories table with sample categories.
and here’s my query sample.
<?php
/Add in our package/
$base_path = !empty($base_path) ? $base_path : $modx->getOption(‘core_path’).‘components/vendors/’;
$vendors = $modx->addPackage(‘vendors’, $base_path.‘model/’);
$output = '';
$cond = $modx->newQuery('vendorCategories');
$cond->where(array(
'parent' => 0
));
$category = $modx->getCollection('vendorCategories', $cond);
//$subs = $category->getMany('Children');
foreach($category as $cat) {
$fields = $cat->toArray();
$output .= $modx->getChunk('product-services-category', $fields);
print_r('<pre class="test">');
print_r($fields);
print_r('</pre>');
}
return $output;
Any help is appreciated, Thank you ')