1
jayjay
Better Xoops select boxes - makeMySelBox beautification
  • 2008/4/24 13:04

  • jayjay

  • Not too shy to talk

  • Posts: 175

  • Since: 2003/9/10


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(".","&nbsp;&nbsp;",$option['prefix']);
                if ( 
$option['prefix'] == "&nbsp;&nbsp;" ) {
                
$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.

2
script_fu
Re: Better Xoops select boxes - makeMySelBox beautification

What select boxes does this effect? Where are the "--" at?

3
jayjay
Re: Better Xoops select boxes - makeMySelBox beautification
  • 2008/4/24 13:36

  • jayjay

  • Not too shy to talk

  • Posts: 175

  • Since: 2003/9/10


Quote:

script_fu wrote:
What select boxes does this effect? Where are the "--" at?


Well, they're everywhere in my admin area... Help!

Seriously now, I see makeMySelBox in wf-links, xoopstube, xdirectory and my hacked wfdownloads. MakeSelBox can be found in the original wfdownloads and in myalbum, among others.

Module developers mostly use these two functions to select categories for your pages or files in admin area.

When you have a lot of categories to select from (50+), it is difficult to differentiate one from the other. The standard XOOPS way is to prefix "--" to subcategories. I believe colours are a lot clearer.

4
script_fu
Re: Better Xoops select boxes - makeMySelBox beautification

lol ok so this is module specific... I could not remember of any dropdowns in core...

Very nice btw Ty!

Login

Who's Online

223 user(s) are online (139 user(s) are browsing Support Forums)


Members: 0


Guests: 223


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits