View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0011420 | phpList 3 application | Documentation | public | 13-09-07 22:36 | 13-02-19 12:27 |
Reporter | Luke The Obscure | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 2.11.3 | ||||
Summary | 0011420: Contribution - columns for checkboxes | ||||
Description | This hack will allow you to create multiple columns for check-boxes. Very handy for larger lists of items! | ||||
Additional Information | I did not write this code, but I found it so useful that I was suprised it's not in the main release. Found in the forumns (line numbers are different in current version): subscribelib2.php: Change 'case "checkboxgroup"' Line 817 to the code below: Code: //-----------------------------------------------------------// case "checkboxgroup": $output[$attr["id"]] .= sprintf("\n".'<tr><td colspan=2><div class="%s">%s</div></td></tr>',$attr["required"] ? 'required' : 'attributename',stripslashes($attr["name"])); $output[$attr["id"]] .='<tr><td colspan=2><table width="100%" border="0" cellspacing="0" cellpadding="1"><tr>'; // creates table within table $values_request = Sql_Query("select * from $table_prefix"."listattr_".$attr["tablename"]." order by listorder,name"); $col = getConfig("checkboxgroupcolumns"); // gets config data $colcount = 1; while ($value = Sql_Fetch_array($values_request)) { if (isset($_POST[$fieldname])) $selected = in_array($value["id"],$_POST[$fieldname]) ? "checked" : ""; else if (isset($data[$attr["id"]])) { $selection = explode(",",$data[$attr["id"]]); $selected = in_array($value["id"],$selection) ? "checked":""; } if($col>1 && $colcount<$col) { $colcount++; $output[$attr["id"]] .= sprintf("\n\t".'<td class="attributeinput"><input type=checkbox name="%s[]" class="attributeinput" value="%s" %s> %s</td>',$fieldname,$value["id"],$selected,stripslashes($value["name"])); } elseif($colcount>=$col) { //inserts new column $output[$attr["id"]] .= sprintf("\n\t".'<td class="attributeinput"><input type=checkbox name="%s[]" class="attributeinput" value="%s" %s> %s</td></tr>'."\n".'<tr>',$fieldname,$value["id"],$selected,stripslashes($value["name"])); $colcount=1; } } $output[$attr["id"]] .= '</tr></table></td></tr>'; //ends table break; //-----------------------------------------------------------// AND in defaultconfig.inc Line 170 Insert the code: Code: //-----------------------------------------------------------// # how many columns checkbox groups will have "checkboxgroupcolumns" => array("2","How many columns would you like to use for CheckBox Groups (numerical)","text"), //-----------------------------------------------------------// | ||||
Tags | No tags attached. | ||||