4
Figured it out, simpler than I thought:
//
// Creates a menu derived from the Database
// Pulls the template, and everything required to make a menu from MySQL
//
function myMenu($which) {
global $xoopsDB;
require_once XOOPS_ROOT_PATH."/class/template.php";
$xoopsTpl = new XoopsTpl;
require XOOPS_ROOT_PATH."/class/xoopsformloader.php";
$form = new XoopsThemeForm("", "buttonmenuform", "index.php");
//
// Read the menu options from the db and make an array of associative arrays (idx)
// then shove the array into a template container for use by a template script
//
$sql = 'SELECT id,label,op,file,template, title
FROM '.$xoopsDB->prefix('bdr_buttons').'
WHERE grp = '.$which.'
ORDER BY id';
$result = $xoopsDB->query($sql);
$i = 0;
$row = array();
$idx = array();
while(list($id,$label,$op,$file,$template, $title) = $xoopsDB->fetchRow($result)) {
$row['label'] = $label;
$row['op'] = $op;
$row['source'] = $file;
$idx[$i] = $row;
$i++;
$xoopsOption['template_main'] = $template;
$xoopsTpl->assign('title',$title);
}
$xoopsTpl->append('idx',$idx);
$form->assign($xoopsTpl);
$xoopsTpl->display('db:'.$xoopsOption['template_main']);
}