老闆覺得每個層級都一樣顏色一樣大小對是使用者太不友善
所以希望可以改善一下
我還以為只是CSS的問題
誰知…那是一個將近耗掉我七個小時的大工程@@
首先在\data\class\helper\SC_Helper_DB.php的sfGetCategoryList()
把層級的參數也傳回來
for($cnt = 0; $cnt < $max; $cnt++) {
$id = $arrRet[$cnt]['category_id'];
$name = $arrRet[$cnt]['category_name'];
$arrList[$id] = "";
$arrLevel[$id] = ""; /*加這一行*/
/*
for($n = 1; $n < $arrRet[$cnt]['level']; $n++) {
$arrList[$id].= " ";
}
*/
for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) {
$arrList[$id].= $head;
}
$arrList[$id].= $name;
$arrLevel[$id]= $arrRet[$cnt]['level'];/*加這一行*/
}
return array($arrList, $arrLevel);/*改這一行*/
\html\user_data\packages\mystyle\bloc\search_products.tpl
\data\module\Smarty\libs\plugins\function.html_options.php的smarty_function_html_options()
讀取層級並放進函式中
foreach($params as $_key => $_val) {
switch($_key) {
case 'name':
$$_key = (string)$_val;
break;
case 'options':
$$_key = (array)$_val;
break;
/*加這一段*/
case 'level':
$$_key = (array)$_val;
break;
..............................
if (isset($options)) {
foreach ($options as $_key=>$_val)
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected,$level[$_key]);/*加這一段$selected,$level[$_key]*/
} else {
foreach ($values as $_i=>$_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected,$level[$_key]); /*加這一段$selected,$level[$_key]*/
}
}
smarty_function_html_options_optoutput()
把層級的參數變成class方便等一下用CSS控制
function smarty_function_html_options_optoutput($key, $value, $selected,$level) {/*加入參數$level*/
if(!is_array($value)) {
$_html_result = '
if (in_array((string)$key, $selected))
$_html_result .= ' selected="selected"';
$_html_result .= ' class="level'.$level. '"'; /*加這一行*/
$_html_result .= '>' . smarty_function_escape_special_chars($value) . '' . "\n";
} else {
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected,$level[$_key]);
}
return $_html_result;
}
smarty_function_html_options_optgroup()
把層級的參數放進函式
function smarty_function_html_options_optgroup($key, $values, $selected,$level) {
$optgroup_html = '' . "\n";
foreach ($values as $key => $value) {
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected,$level[$_key]);/*加入參數$level*/
}
$optgroup_html .= "\n";
return $optgroup_html;
}
\user_data\packages\mystyle\css\default-css.css加上一段
終於可以用CSS控制了
不過….為什麼只有顏色有效阿@@
.box142 .level1{
color:#FF6600;
}
終於搞定了@@