1
Hi everybody!
I beautified makeMySelBox a bit. The standard XOOPS select boxes are a pain to use when you have a lot of module categories. This will give background colours to different category levels, instead of those dashes "--" we have now.
Edit class/xoopstree.php:
//makes a nicely ordered selection box
//$preset_id is used to specify a preselected item
//set $none to 1 to add a option with value 0
function makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="")
{
if ( $sel_name == "" ) {
$sel_name = $this->id;
}
$myts =& MyTextSanitizer::getInstance();
echo "<select name='".$sel_name."'";
if ( $onchange != "" ) {
echo " onchange='".$onchange."'";
}
echo ">n";
$sql = "SELECT ".$this->id.", ".$title." FROM ".$this->table." WHERE ".$this->pid."=0";
if ( $order != "" ) {
$sql .= " ORDER BY $order";
}
$result = $this->db->query($sql);
if ( $none ) {
echo "<option value='0'>----</option>n";
}
while ( list($catid, $name) = $this->db->fetchRow($result) ) {
$sel = "";
if ( $catid == $preset_id ) {
$sel = " selected='selected'";
}
echo "<option class='title' value='$catid'$sel>$name</option>n"; //edit jayjay
$sel = "";
$arr = $this->getChildTreeArray($catid, $order);
foreach ( $arr as $option ) {
//start edit jayjay
$option['prefix'] = str_replace("."," ",$option['prefix']);
if ( $option['prefix'] == " " ) {
$option['prefix'] = substr($option['prefix'], 6);
$catpath = $option['prefix'].$myts->makeTboxData4Show($option[$title]);
if ( $option[$this->id] == $preset_id ) {
$sel = " selected='selected'";
}
echo "<option class='title2' value='".$option[$this->id]."'$sel>$catpath</option>n";
}
else {
$catpath = $option['prefix'].$myts->makeTboxData4Show($option[$title]);
if ( $option[$this->id] == $preset_id ) {
$sel = " selected='selected'";
}
echo "<option value='".$option[$this->id]."'$sel>$catpath</option>n";
}
//end edit jayjay
$sel = "";
}
}
echo "</select>n";
}
Edit xoops.css:
option.title {
background-color:#ddd;
color:#000;
}
option.title2 {
background-color:#F2F2F2;
color:#000;
}
Change colors and add subcategories to your liking!
I guess a similar thing can be done to makeSelBox in class/tree.php.