【发布时间】:2016-05-31 01:10:23
【问题描述】:
首先,我必须告诉你,我在这方面的经验很少。我遇到的问题是我正在尝试将 Joomla 生成的网站重新编码为将复选框显示为过滤器。现在我正在使用一个有效的多选列表,但我需要有复选框(这样用户在选择多个值时不需要按住 Shift 或 Ctrl)。有两个过滤器(一个用于州,另一个用于城市),城市的过滤器选项是根据州过滤器中的选择生成的。我不知道如何将所有内容都变成复选框,从而根据“州”区域中的复选框继续生成“城市复选框”...
public static function makeStateList($req_country_id,$req_state_id,$name,$onChange,$firstOption,$style,$class="input-medium"){
global $configClass,$languages;
$db = JFactory::getDbo();
$stateArr = array();
$show_available_states_cities = $configClass['show_available_states_cities'];
$lgs = OSPHelper::getLanguages();
$translatable = JLanguageMultilang::isEnabled() && count($lgs);
$suffix = "";
if($translatable){
$suffix = OSPHelper::getFieldSuffix();
}
if((!HelperOspropertyCommon::checkCountry()) or ($req_country_id > 0)){
$query = "Select id as value,state_name".$suffix." as text from #__osrs_states where published = 1 ";
if($req_country_id > 0){
$query .= " and country_id = '$req_country_id'";
}else{
$query .= " and country_id = '".$configClass['show_country_id']."'";
}
if($show_available_states_cities == 1){
$query .= " and id in (Select state from #__osrs_properties where approved = '1' and published = '1')";
}
$query .= " order by state_name";
$db->setQuery($query);
$states = $db->loadObjectList();
if($firstOption != ""){
$stateArr[] = JHTML::_('select.option','',$firstOption);
$stateArr = array_merge($stateArr,$states);
}else{
$stateArr = $states;
}
return JHTML::_('select.genericlist',$stateArr,$name,'class="'.$class.'" multiple="multiple" '.$onChange.' '.$style,'value','text',$req_state_id);
}else{
$stateArr[] = JHTML::_('select.option','',$firstOption);
return JHTML::_('select.genericlist',$stateArr,$name,'class="'.$class.'" disabled','value','text');
}
}
/**
* Load City
*
* @param unknown_type $option
* @param unknown_type $state_id
* @param unknown_type $city_id
* @return unknown
*/
public static function loadCity($option,$state_id,$city_id,$class="input-medium"){
global $mainframe,$configClass,$languages;
$db = JFactory::getDBO();
$lgs = OSPHelper::getLanguages();
$translatable = JLanguageMultilang::isEnabled() && count($lgs);
$suffix = "";
if($translatable){
$suffix = OSPHelper::getFieldSuffix();
}
$availSql = "";
$show_available_states_cities = $configClass['show_available_states_cities'];
$cityArr = array();
$cityArr[]= JHTML::_('select.option','',JText::_('OS_ALL_CITIES'));
if($state_id > 0){
if($show_available_states_cities == 1){
$availSql = " and id in (Select city from #__osrs_properties where approved = '1' and published = '1')";
}
$db->setQuery("Select id as value, city".$suffix." as text from #__osrs_cities where published = '1' $availSql and state_id = '$state_id' order by city");
$cities = $db->loadObjectList();
$cityArr = array_merge($cityArr,$cities);
$disabled = "";
}else{
$disabled = "disabled";
}
return JHTML::_('select.genericlist',$cityArr,'city','class="'.$class.'" '.$disabled,'value','text',$city_id);
}
抱歉,帖子太长了。我希望这是有道理的...感谢您的所有帮助!
【问题讨论】:
标签: php jquery checkbox joomla multi-select