Ri-buongiorno, una domanda, sul sito
www.lecasediparma.it ho alcuni moduli filtri (3 per l'esattezza) vorrei modificare questo modulo in modo da fargli scegliere in automatico nella casella "provincia" la option Parma così da poterla poi non visualizzare (perchè già scelta).
Metto il codice del php che gestisce il modulo, magari può aiutare
<?php
/**
* @package mod_bt_property_filter
* @version 1.0
* @created Apr 2013
* @author BowThemes
* @email support@bowthems.com
* @website http://bowthemes.com
* @support Forum - http://bowthemes.com/forum/
* @copyright Copyright (C) 2012 Bowthemes. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
$location_levels = JComponentHelper::getParams('com_bt_property')->get('location_levels','3');
$advancedSearch = '';
if($extrafield){
foreach ($extrafield as $id => $extraoption) :
if (isset($extraoption->checked)) {
$advancedSearch .= '<div class="form-group">';
switch ($extraoption->type) {
case 'dropdown':
$advancedSearch .= BTPropertyFilterHelper::extrafield_select($params,$extraoption->value, $id);
break;
case 'multiple':
$advancedSearch .= BTPropertyFilterHelper::extrafield_multiple($params,$extraoption->value, $id);
break;
case 'radio':
$advancedSearch .= BTPropertyFilterHelper::extrafield_radio($params,$extraoption->value, $id);
break;
case 'checkbox':
$advancedSearch .= BTPropertyFilterHelper::extrafield_checkbox($params, $extraoption->value,$id);
break;
case 'select':
$advancedSearch .= BTPropertyFilterHelper::extrafield_measure($params, $extraoption->value, $id);
break;
case 'texrange':
$advancedSearch .= BTPropertyFilterHelper::extrafield_textrange($params, $extraoption->value,$id);
break;
case 'checkboxlist':
$advancedSearch .= BTPropertyFilterHelper::extrafield_checkboxlist($params, $id);
break;
case'textbox':
$advancedSearch .= BTPropertyFilterHelper::extrafield_textbox($params,$extraoption->value,$id);
break;
}
$advancedSearch .= '<>';
}
endforeach;
}
?>
<div class="btp bt-propertyfilter<?php echo $moduleclass_sfx; ?>">
<form role="form" id="form-map" class="form-map form-search" action="<?php echo JRoute::_(BT_PropertyHelperRoute::getCategoryRoute(0)); ?>"
name="BTFilter" method="get">
<input type="hidden" name="task" value="filter" />
<input type="hidden" name="option" value="com_bt_property" />
<input type="hidden" name="view" value="properties" />
<?php if ($showsearchbox == 1) { ?>
<div class="form-group">
<?php echo BTPropertyFilterHelper::input_text($params, $keysearch); ?>
<>
<?php } ?>
<?php if ($showstatus == 1) { ?>
<div class="form-group">
<?php echo BTPropertyFilterHelper::itemselect($params, 'prstatus'); ?>
<>
<?php } ?>
<?php if ($showlocation == 1) { ?>
<div class="form-group">
<?php echo BTPropertyFilterHelper::itemselect($params, 'location_lv1'); ?>
<>
<?php if($location_levels > 1 ) { ?>
<div class="form-group">
<?php echo BTPropertyFilterHelper::itemselect($params, 'location_lv2'); ?>
<>
<?php }?>
<?php if($location_levels > 2 ) { ?>
<div class="form-group">
<?php echo BTPropertyFilterHelper::itemselect($params, 'location_lv3'); ?>
<>
<?php }?>
<?php } ?>
<?php
if ($showcategory == 1) {
if ($params->get('category', '')) {
echo '<input type="hidden" name="category_select" value="' . $params->get('category') . '"/>';
} else {
?>
<div class="form-group">
<?php echo BTPropertyFilterHelper::categoryselect($params); ?>
<>
<?php }
}?>
<?php if ($showprice) { ?>
<div class="form-group">
<?php echo BTPropertyFilterHelper::priceRange($params); ?>
<>
<?php } ?>
<?php if ($advancedSearch) { ?>
<div class="form-group">
<h4><a onclick="jQuery('#advanced-search').slideToggle();return false;" href="#"><?php echo JText::_('FILTER_ADVANCED_SEARCH');?>[/url]</h4>
<div style="display:none" id="advanced-search">
<?php echo $advancedSearch ?>
<>
<>
<?php } ?>
<div class="filter-description">
<?php
echo $descr;
?>
<>
<div class="filter-button">
<input type="hidden" name="method" value="<?php echo $method ?>" />
<input type="submit" value="<?php echo $buttontext; ?>" class="btn btn-default" />
<?php if ($Itemid)
echo '<input type="hidden" name="Itemid" value="' . $Itemid . '" />';
?>
<>
</form>
<>
mentre questo sarebbe il codice del file helper.php
<?php
/**
* @package mod_bt_property_filter
* @version 1.1
* @created Apr 2013
* @author BowThemes
* @email support@bowthems.com
* @website http://bowthemes.com
* @support Forum - http://bowthemes.com/forum/
* @copyright Copyright (C) 2012 Bowthemes. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
class BTPropertyFilterHelper {
public static function hasChildren($id) {
$mainframe = JFactory::getApplication();
$id = (int) $id;
$db = JFactory::getDBO();
$query = 'SELECT * FROM #__bt_property_categories WHERE parent_id='.$id.' AND published = 1 AND language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')';
$db->setQuery($query);
$rows = $db->loadObjectList();
if ($db->getErrorNum()) {
$html .= $db->stderr();
return false;
}
if (count($rows)) {
return true;
} else {
return false;
}
}
public static function input_text(&$params,$opensearch_title){
$html = '';
$value= JRequest::getVar('searchword');
$html .= '<input name="searchword" class="inputbox" type="text" value="'. $value .'" placeholder="'.$opensearch_title.'" />';
return $html;
}
public static function categoryselect(&$params, $id = 0, $level = 0) {
$root_id = "";
$category = JRequest::getVar('category_select');
if(!$category && $params->get('auto_detect_category', 0)){
$app = JFactory::getApplication();
$categoryId = $app->input->getInt('catid') ? $app->input->getInt('catid') : $app->input->getInt('catid_rel');
if($app->input->get('option') == 'com_bt_property' && $categoryId){
$category = $categoryId;
}
}
$id = (int) $id;
$db = JFactory::getDBO();
$query = "SELECT * FROM #__bt_property_categories WHERE parent_id={$id} AND published=1 ";
$query .= ' AND language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')';
$query .= " ORDER BY ordering";
$db->setQuery($query);
$rows = $db->loadObjectList();
if ($db->getErrorNum()) {
echo $db->stderr();
return false;
}
$html = '';
if($level == 0) {
$html .= "<select name=\"category_select\">";
$html .= "<option value=\"\">".JText::_("COM_BT_PROPERTY_CATEGORY")."</option>";
}
$indent = "";
for ($i = 0; $i < $level; $i++) {
$indent .= '– ';
}
foreach ($rows as $k => $row) {
if (($category == $row->id)) {
$selected = ' selected';
} else {
$selected = '';
}
if (BTPropertyFilterHelper::hasChildren($row->id)) {
$html .= '<option value="'.$row->id.'"'.$selected.'>'.$indent.$row->title.'</option>';
$html .= BTPropertyFilterHelper::categoryselect($params, $row->id, $level + 1, $i);
} else {
$html .= '<option value="'.$row->id.'"'.$selected.'>'.$indent.$row->title.'</option>';
}
}
if ($level == 0) {
$html .= "</select>";
}
return $html;
}
public static function itemSelect(&$params,$type) {
$value = JRequest::getVar($type);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id AS value, title AS text');
$query->from('#__bt_property_items');
$query->where('published=1');
$query->where('type=\''.$type.'\'');
$query->order('title');
$db->setQuery($query);
if($type=='location_lv2'){
$query->where('parent_id = '.JRequest::getInt('location_lv1'));
}else if($type=='location_lv3'){
$query->where('parent_id = '.JRequest::getInt('location_lv2'));
}
$options = $db->loadObjectList();
foreach ($options as & $option){
$option->text = JText::_($option->text);
}
$label = str_replace('prstatus','status',$type);
$label = strtoupper($label);
$options = array_merge(array(JHtml::_('select.option','', JText::_('COM_BT_PROPERTY_'.$label))), $options);
return JHtml::_('select.genericlist', $options, $type, 'class="item_'.$type.'"', 'value', 'text',$value);
}
public static function extrafield_select(&$params,$extravalue,$extraid) {
$db = JFactory::getDBO();
$query = "SELECT * FROM #__bt_property_extrafields WHERE id IN ($extraid) AND published=1 ";
$db->setQuery($query);
$rows = $db->loadObjectList();
$html = '';
$selected= '';
foreach ($rows as $k => $row) {
if(!trim($extravalue) && $row->type == "dropdown"){
$option = $row->default_value;
$items = explode("\r\n", $option);
}else{
$items = explode(",", $extravalue);
$items = BTPropertyFilterHelper::remove_array_empty_values($items);
}
if(!count($items)){
$items = self::getExistingValues($extraid);
}
$html .= '<div class="ex-'.preg_replace("/[^a-zA-Z0-9]/", "", strtolower($row->name)).'">';
$html .= "<div class=\"filter-content\">";
$html .= "<input type=\"hidden\" name=\"extraid[".$extraid."]\" value=\"$row->id\">";
$html .= "<select name=\"extraselect[".$extraid."]\">";
$html .= "<option value=\"\">".$row->name."</option>";
$extra_select = JRequest::getVar('extraselect', null);
foreach($items as $item){
if(isset($extra_select[$extraid]) && $extra_select[$extraid] == $item){
$selected = ' selected="selected"';
} else {
$selected = '';
}
if($item!=""){
$html .= '<option value="'.$item.'"'.$selected.'>'.$item.'</option>';
}
}
$html .= "
</select>
<>
<>
";
}
return $html;
}
public static function extrafield_textbox(&$params,$extravalue,$extraid) {
$db = JFactory::getDBO();
$query = "SELECT * FROM #__bt_property_extrafields WHERE id IN ($extraid) AND published=1 ";
$db->setQuery($query);
$rows = $db->loadObjectList();
$html = '';
$selected= '';
foreach ($rows as $k => $row) {
$html .= '<div class="ex-'.preg_replace("/[^a-zA-Z0-9]/", "", strtolower($row->name)).'">';
$html .= "<div class=\"filter-label\">";
$html .= "<label>".$row->name."</label>";
$html .="<>";
$html .= "<div class=\"filter-content\">";
$extra_select = JRequest::getVar('exl-values', null);
$html .= '<input class="inputbox" type="text" name="exl-values['.$extraid.']" value="'.(isset($extra_select[$extraid])? $extra_select[$extraid]:'').'" >';
$html .= "<><>";
}
return $html;
}
public static function extrafield_multiple(&$params,$extravalue,$extraid){
$db = JFactory::getDBO();
$query = "SELECT * FROM #__bt_property_extrafields WHERE id IN ($extraid) AND published=1 ";
$db->setQuery($query);
$rows = $db->loadObjectList();
$html = '';
foreach ($rows as $k => $row) {
if(!trim($extravalue) && $row->type == "dropdown"){
$option =$row->default_value;
$items = explode("\r\n", $option);
}else{
$items = explode(",", $extravalue);
$items =BTPropertyFilterHelper::remove_array_empty_values($items);
}
if(!count($items)){
$items = self::getExistingValues($extraid);
}
$html .= '<div class="ex-'.preg_replace("/[^a-zA-Z0-9]/", "", strtolower($row->name)).'">';
$html .= "<div class=\"filter-content\">";
$html .= "<input type=\"hidden\" name=\"extraarrayid[".$extraid."]\" value=\"$row->id\">";
$html .= "<select name=\"extraselect_array[".$extraid."][]\" multiple=\"multiple\">";
$html .= "<option value=\"\">".$row->name."</option>";
$extra_multiple =JRequest::getVar('extraselect_array', null);
foreach($items as $item){
$selected = '';
if(is_array($extra_multiple)==true) {
foreach($extra_multiple as $key=> $multi) {
if(is_array($multi)){
foreach($multi as $itemvalue){
if ($itemvalue == $item) {
$selected = ' selected';
break;
} else {
$selected = '';
}
}
}
}
}else {
if($extra_multiple == $item)
$selected = 'selected';
}
if($item!=""){
$html .= '<option value="'.$item.'"'.$selected.'>'.$item.'</option>';
}
}
$html .= "
</select>
<>
<>
";
}
return $html;
}
public static function extrafield_radio(&$params,$extravalue,$extraid){
$db = JFactory::getDBO();
$query = "SELECT * FROM #__bt_property_extrafields WHERE id IN ($extraid) AND published=1 ";
$db->setQuery($query);
$rows = $db->loadObjectList();
$html = '';
foreach ($rows as $k => $row) {
if(!trim($extravalue) && $row->type == "dropdown"){
$option =$row->default_value;
$items = explode("\r\n", $option);
}else{
$items = explode(",", $extravalue);
$items =BTPropertyFilterHelper::remove_array_empty_values($items);
}
if(!count($items)){
$items = self::getExistingValues($extraid);
}
$html .= '<div class="ex-'.preg_replace("/[^a-zA-Z0-9]/", "", strtolower($row->name)).'">';
$html .= "<div class=\"filter-label\">";
$html .= "<input type=\"hidden\" name=\"extraid[".$extraid."]\" value=\"$row->id\">";
$html .= "<label>".$row->name."</label>";
$html .="<>";
$html .= "<div class=\"filter-content\">";
$extra_select = JRequest::getVar('extraselect', null);
foreach($items as $item){
if(isset($extra_select[$extraid]) && $extra_select[$extraid] == $item){
$selected = ' checked="checked"';
} else {
$selected = '';
}
$html .= '<input name="extraselect['.$extraid.']" type="radio" value="'.$item.'"';
$html .= ''.$selected.'';
$html .= ' /><label for="'.$item.'">'.$item.'</label>[br /]';
}
$html .= '<>';
$html .= '<>';
}
return $html;
}
public static function extrafield_checkbox(&$params,$extravalue,$extraid){
$db = JFactory::getDBO();
$query = "SELECT * FROM #__bt_property_extrafields WHERE id IN ($extraid) AND published=1 ";
$db->setQuery($query);
$rows = $db->loadObjectList();
$html = '';
foreach ($rows as $k => $row) {
if(!trim($extravalue) && $row->type == "dropdown"){
$option =$row->default_value;
$items = explode("\r\n", $option);
}else{
$items = explode(",", $extravalue);
$items =BTPropertyFilterHelper::remove_array_empty_values($items);
}
if(!count($items)){
$items = self::getExistingValues($extraid);
}
$html .= '<div class="ex-'.preg_replace("/[^a-zA-Z0-9]/", "", strtolower($row->name)).'">';
$html .= "<div class=\"filter-label\">";
$html .= "<input type=\"hidden\" name=\"extraarrayid[".$extraid."]\" value=\"$row->id\">";
$html .= "<label>".$row->name."</label>";
$html .= "<>";
$html .= "<div class=\"filter-content\">";
$searchchk = JRequest::getVar('extraselect_array', null);
$search = array();
(is_array($searchchk) == false) ? $search[] = $searchchk : $search = $searchchk ;
foreach($items as $item){
$html .= '<input name="extraselect_array['.$extraid.'][]" type="checkbox" value="'.$item.'"';
foreach ($search as $arraysearch) {
if(is_array($arraysearch)){
foreach($arraysearch as $itemvalue){
if (trim($itemvalue) == trim($item)) $html .= 'checked="checked"';
}
}
}
$html .= ' /><label for="'.$item.'">'.$item.'</label>[br /]';
}
$html .="<>";
$html .="<>";
}
return $html;
}
public static function extrafield_measure(&$params,$extravalue,$extraid){
$db = JFactory::getDBO();
$cparams = JComponentHelper::getParams("com_bt_property");
$items = explode(",", $extravalue);
$items =BTPropertyFilterHelper::remove_array_empty_values($items);
$query = "SELECT * FROM #__bt_property_extrafields WHERE type=\"measurement\" AND id=$extraid AND published=1 ";
$db->setQuery($query);
$rows = $db->loadObjectList();
$arrayunit = @unserialize($rows[0]->default_value);
$selected = '';
$html = '';
sort($items);
if(!count($items)){
$items = self::getExistingValues($extraid);
}
$html .= '<div class="ex-'.preg_replace("/[^a-zA-Z0-9]/", "", strtolower($rows[0]->name)).' range-validator">';
$html .= '<div class="ex-min">';
$html .= "<div class=\"filter-label\">";
$html .= "<input type=\"hidden\" name=\"exmeasureID[".$extraid."]\" value=\"$extraid\">";
$html .= "<label>".sprintf(JText::_('MEASUREMENT_MIN'),$rows[0]->name).($arrayunit[1]? ' ('.$arrayunit[1].') ':'')."</label>";
$html .= "<>";
$extra_min = JRequest::getVar('extra_min', null);
$html .= "<div class=\"filter-content\">";
$html .= "<select name=\"extra_min[".$extraid."]\">";
$total = count($items);
$selected ='';
for ($i= 0;$i< count($items);$i++){
if (isset($extra_min[$extraid])){
if($extra_min[$extraid] == $items[$i]){
$selected = ' selected';
}else{
$selected = '';
}
}
$html .= '<option value="'.($items[$i]).'"'.$selected.'>'.number_format($items[$i], 0, $cparams->get('decimal_symbol', '.'), $cparams->get('thousands_sep', ',')).'</option>';
}
$html .= "</select>";
$html .= '<>';
$html .= '<>';
//Max select
$sl ="";
$extra_max = JRequest::getVar('extra_max', null);
$html .= '<div class="ex-max">';
$html .= "<div class=\"filter-label\">";
$html .= "<label>".sprintf(JText::_('MEASUREMENT_MAX'),$rows[0]->name).($arrayunit[1]? ' ('.$arrayunit[1].') ':'')."</label>";
$html .="<>";
$html .= "<div class=\"filter-content\">";
$html .= "<select name=\"extra_max[".$extraid."]\">";
$selected = '';
for ($i= 0;$i< $total;$i++){
if (isset($extra_max[$extraid])){
if($extra_max[$extraid] == $items[$i]){
$selected = ' selected';
}else{
$selected = '';
}
} else {
if(!$selected && $i == $total-1){
$selected = ' selected';
}
}
$html .= '<option value="'.($items[$i]).'"'.$selected.'>'.number_format($items[$i], 0, $cparams->get('decimal_symbol', '.'), $cparams->get('thousands_sep', ',')).'</option>';
}
$html .= "</select>";
$html .= '<>';
$html .= '<>';
$html .= '<>';
return $html;
}
public static function extrafield_textrange(&$params,$extravalue,$extraid){
$db = JFactory::getDBO();
$query = "SELECT * FROM #__bt_property_extrafields WHERE id IN ($extraid) AND published=1 ";
$db->setQuery($query);
$row = $db->loadObject();
$arrayunit = @unserialize($row->default_value);
$html = '';
$selected = '';
$html .= '<div class="ex-'.preg_replace("/[^a-zA-Z0-9]/", "", strtolower($row->name)).'">';
$html .= "<div class=\"filter-label\">";
$html .= "<label>".sprintf(JText::_('MEASUREMENT_FROM'),$row->name).($arrayunit[1]? ' ('.$arrayunit[1].') ':'')."</label>";
$html .="<>";
$extra_from = JRequest::getVar('extra_from', null);
$html .='<input type="hidden" name="exTextID[]" value="'.$extraid.'"/><input name="extra_from['.$extraid.']" value="'.($extra_from?$extra_from[$extraid]:'').'" />';
$extra_to = JRequest::getVar('extra_to', null);
$html .= "<div class=\"filter-label\">";
$html .= "<label>".sprintf(JText::_('MEASUREMENT_TO'),$row->name).($arrayunit[1]? ' ('.$arrayunit[1].') ':'')."</label>";
$html .="<>";
$html .='<input name="extra_to['.$extraid.']" value="'.($extra_to?$extra_to[$extraid]:'').'" />';
$html .="<>";
return $html;
}
public static function extrafield_checkboxlist(&$params,$extraid){
$db = JFactory::getDBO();
$query = "SELECT * FROM #__bt_property_extrafields WHERE id IN ($extraid) AND published=1 ";
$db->setQuery($query);
$row = $db->loadObject();
if($row){
$html = '<header><h3>'.$row->name.'</h3></header>';
$html .= '<ul class="submit-features">';
$options = explode("\n",$row->default_value);
$exCblist = JRequest::getVar('exCblist', array());
if(isset($exCblist[$extraid])){
$exCblist = $exCblist[$extraid];
}else{
$exCblist = array();
}
foreach($options as $option){
$html.= '<li>';
$checked = '';
foreach($exCblist as $value){
if(trim($value) == trim($option)){
$checked = 'checked="checked"';
break;
}
}
$html.= '<div class="checkbox"><label><input name="exCblist['.$extraid.'][]" value="'.htmlspecialchars($option).'" '.$checked.' type="checkbox">'.$option.'</label><>';
$html.= '</li>';
}
$html .= '</ul>';
return $html;
}
return '';
}
/** PRICE FILTER FUNCTION **/
public static function priceRange($params){
$html = '';
switch($params->get('showprice')){
case 1:
// Slider
$range = $params->get('pricerange','1000;299000');
$curRange = JFactory::getApplication()->input->getString('price', $range);
if(!$curRange) $curRange = $range;
$range = explode(';',$range);
list($curFrom, $curTo) = explode(';', $curRange);
if($curFrom<$range[0]){
$curFrom = $range[0];
}
if($curTo>$range[1]){
$curTo = $range[1];
}
$step = $params->get('pricestep',1000);
$uniqueId = rand(0, 1000);
$cparams = JComponentHelper::getParams("com_bt_property");
$price_format = $cparams->get('price_format', '$ 000');
$currency = $cparams->get('currency', 'USD');
$currency = html_entity_decode(Bt_propertyLegacyHelper::getCurrencySymbols($currency),ENT_COMPAT, 'UTF-8');
$price_format = str_replace(array('000','$'), array('###'.$cparams->get('thousands_sep',',').'###',$currency), $price_format);
$html = '<div class="price-range"><input id="price-input'.$uniqueId.'" type="text" name="price" value="'.$curFrom.';'.$curTo.'"><>';
$html .= '<script type="text/javascript">
BTP(document).ready(function(){
BTP("#price-input'.$uniqueId.'").slider({
from: '.$range[0].',
to: '.$range[1].',
step: '.$step.',
round: 1,
format: { format: \''.$price_format.'\', locale: \'en\' }
});});</script>';
break;
case 2:
// One Dropdown List only
$priceValues = $params->get('pricevalues','1000,2000,5000,10000,20000,50000,100000');
$priceValues = explode(',',$priceValues);
$options = array();
$options[] = JHtml::_('select.option','', JText::_('COM_BT_PROPERTY_PRICE'));
foreach($priceValues as $value){
$options[] = JHtml::_('select.option',$value, str_replace(' ','',Bt_propertyHelper::formatPrice($value)). ' +');
}
$html = JHtml::_('select.genericlist', $options, "price_from", '', 'value', 'text',JFactory::getApplication()->input->getString('price_from'), '');
break;
case 3:
//Range Two Dropdown Lists
$priceValues = $params->get('pricevalues','1000,2000,5000,10000,20000,50000,100000');
$priceValues = explode(',',$priceValues);
$options = array();
$options[] = JHtml::_('select.option','', JText::_('FILTER_SELECT_PRICE_FROM'));
foreach($priceValues as $value){
$options[] = JHtml::_('select.option',$value, Bt_propertyHelper::formatPrice($value));
}
$html .= '<div class="filter-label"><label>'.JText::_('COM_BT_PROPERTY_PRICE').'</label><>';
$html .= '<div class="range-validator">';
$html .= JHtml::_('select.genericlist', $options, "price_from", 'class="price_range"', 'value', 'text',JFactory::getApplication()->input->getString('price_from'), '');
$options[0] = JHtml::_('select.option','', JText::_('FILTER_SELECT_PRICE_TO'));
$html .= JHtml::_('select.genericlist', $options, "price_to", 'class="price_range price_range_right"', 'value', 'text',JFactory::getApplication()->input->getString('price_to'), '');
$html .= '<>';
break;
case 4:
//Range Text Box & Auto complete HTML5
$priceValues = $params->get('pricevalues','1000,2000,5000,10000,20000,50000,100000');
$priceValues = explode(',',$priceValues);
$options = array();
foreach($priceValues as $value){
$options[] = JHtml::_('select.option',$value, Bt_propertyHelper::formatPrice($value));
}
$html .= '<div class="filter-label"><label>'.JText::_('COM_BT_PROPERTY_PRICE').'</label><>';
$html .= '<input autocomplete="off" type="text" placeholder="'.JText::_('FILTER_SELECT_PRICE_FROM').'" class="price_range" name="price_from" value="'.JFactory::getApplication()->input->getString('price_from').'" list="datalist1">';
$html .= '<input autocomplete="off" type="text" placeholder="'.JText::_('FILTER_SELECT_PRICE_TO').'" class="price_range price_range_right" name="price_to" value="'.JFactory::getApplication()->input->getString('price_to').'" list="datalist1">';
$html .= '<datalist id="datalist1">';
foreach($options as $option){
$html .= '<option value="'.$option->value.'">'.$option->text.'</option]>';
}
$html .= '</datalist>';
break;
}
return $html;
}
public static function remove_array_empty_values($array)
{
$new_array = array();
$null_exceptions = array();
foreach ($array as $key => $value)
{
$value = trim($value);
if(!in_array($value, $null_exceptions) && $value != "")
{
$value = htmlspecialchars($value);
$new_array[] = $value;
}
}
return $new_array;
}
public static function getExistingValues($extraid){
if($extraid){
$db = JFactory::getDBO();
$query = "SELECT DISTINCT(`value`) FROM #__bt_property_extrafields_values WHERE `value` is not null and `value` != '' and extrafields_id = ".intval($extraid). ' order by `value` limit 100';
$db->setQuery($query);
return self::remove_array_empty_values($db->loadColumn());
}
return array();
}
}