- Posts: 3
COMMUNITY FORUM
checkbox in extrafield with searching problem :/
- mach
-
Topic Author
- Offline
- New Member
Less
More
13 years 10 months ago #97397
by mach
checkbox in extrafield with searching problem :/ was created by mach
ı think i have been solved the problem which is checkbox selection in extrafield but ı couldn't apply it to be searchable in ja k2 search plugin. After saving the item it doesn't update the ja plugin database table. When ı use the reindexing it updates but after if ı do some changing in item then ı save the data rows in table is become empty how can ı overcome...
ı add the checbox in extrafiled by this way
first of all i added some code in the libraries/joomla/htmla/html/select.php
function checkboxGroup( $arr, $name, $attribs = null, $key = 'value', $text = 'text', $selected = NULL , $idtag = false, $translate = false ) { reset( $arr ); $html = ''; if (is_array($attribs)) { $attribs = JArrayHelper::toString($attribs); } $id_text = $name; if ( $idtag ) { $id_text = $idtag; } foreach ($arr as $i => $option) { $element =& $arr[$i]; // since current doesn't return a reference, need to do this $isArray = is_array( $element ); $extra = ''; if ($isArray) { $k = $element[$key]; $t = $element[$text]; $id = ( isset( $element ) ? $element : null ); } else { $k = $element->$key; $t = $element->$text; $id = ( isset( $element->id ) ? $element->id : null ); } $splitText = explode( ' - ', $t, 2 ); $t = $splitText[0]; if(isset($splitText[1])){ $t .= ' - '. $splitText[1]; } $extra = ''; $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; if (is_array( $selected )) { foreach ($selected as $val) { $k2 = is_object( $val ) ? $val->$key : $val; if ($k == $k2) { $extra .= " checked=\"checked\""; break; } } } else { $extra .= ((string)$k == (string)$checked ? " checked=\"checked\"" : ''); } //if flag translate text if ($translate) { $t = JText::_( $t ); } // ensure ampersands are encoded $k = JFilterOutput::ampReplace($k); $t = JFilterOutput::ampReplace($t); $id_text = str_replace('','', $id_text); $html .= "\n\t<label for=\"$id_text$k\">$t</label>"; $html .= "\n\t<input type=\"checkbox\" name=\"$name\" id=\"$id_text$k\" value=\"".$k."\"$extra $attribs />"; } return $html; }
ı try to mix radio and option function to be appriopriate to use by checboxlist
in the administrator/component/com_k2/model/extrafield.php
i added some code piece on line 60 to be like this
if ($row->type=='select' || $row->type=='multipleSelect' || $row->type=='radio' || $row->type=='checkbox'){ $object->set('value', $i+1); }
and some another on line 162
if ($extraField->type=='textfield' || $extraField->type=='csv' || $extraField->type=='labels' || $extraField->type=='checkbox' ) $active=$value->value;
some another on line 222
case 'checkbox': $output=JHTML::_('select.checkboxGroup', $defaultValues, 'K2ExtraField_'.$extraField->id.'[]','', 'value', 'name', $active); break;
and added on line 291 to be searchable
else if ($row->type=='multipleSelect' || $extraField->type=='checkbox'){ foreach ($jsonObject as $option){ if (in_array($option->value,$currentValue)) $value.=$option->name.' '; } }
in the
in the administrator/component/com_k2/view/extrafiled/extrafield.php
i added on line 48
$typeOptions[] = JHTML::_('select.option', 'checkbox', JText::_('Checkbox list'));
and in the administrator/component/com_k2/view/extrafiled/tmpl/default.php
i added case 'checkbox': under case 'multipleSelect':
i hope ı can be helpfull it is my first post to help peope this is important for me. I try to make realestate site by using k2 so checkboxes so important for tihs like search module and plugin but the advanced search not enough to do this how can ı overcome this poblem. ı couldnt solve the search problem checkboxes if anyone do this i appraciate him/her. İn addiiton ı can choose which extrafields are shown in module but the system of plugin and module is the same how can ı seperate this. I want to show some extrafiled in module in the some where but ı dont want to show anotherwhere it must be choosable. Thank you for reading. I am waiting for helpfull replies.
ı add the checbox in extrafiled by this way
first of all i added some code in the libraries/joomla/htmla/html/select.php
function checkboxGroup( $arr, $name, $attribs = null, $key = 'value', $text = 'text', $selected = NULL , $idtag = false, $translate = false ) { reset( $arr ); $html = ''; if (is_array($attribs)) { $attribs = JArrayHelper::toString($attribs); } $id_text = $name; if ( $idtag ) { $id_text = $idtag; } foreach ($arr as $i => $option) { $element =& $arr[$i]; // since current doesn't return a reference, need to do this $isArray = is_array( $element ); $extra = ''; if ($isArray) { $k = $element[$key]; $t = $element[$text]; $id = ( isset( $element ) ? $element : null ); } else { $k = $element->$key; $t = $element->$text; $id = ( isset( $element->id ) ? $element->id : null ); } $splitText = explode( ' - ', $t, 2 ); $t = $splitText[0]; if(isset($splitText[1])){ $t .= ' - '. $splitText[1]; } $extra = ''; $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; if (is_array( $selected )) { foreach ($selected as $val) { $k2 = is_object( $val ) ? $val->$key : $val; if ($k == $k2) { $extra .= " checked=\"checked\""; break; } } } else { $extra .= ((string)$k == (string)$checked ? " checked=\"checked\"" : ''); } //if flag translate text if ($translate) { $t = JText::_( $t ); } // ensure ampersands are encoded $k = JFilterOutput::ampReplace($k); $t = JFilterOutput::ampReplace($t); $id_text = str_replace('','', $id_text); $html .= "\n\t<label for=\"$id_text$k\">$t</label>"; $html .= "\n\t<input type=\"checkbox\" name=\"$name\" id=\"$id_text$k\" value=\"".$k."\"$extra $attribs />"; } return $html; }
ı try to mix radio and option function to be appriopriate to use by checboxlist
in the administrator/component/com_k2/model/extrafield.php
i added some code piece on line 60 to be like this
if ($row->type=='select' || $row->type=='multipleSelect' || $row->type=='radio' || $row->type=='checkbox'){ $object->set('value', $i+1); }
and some another on line 162
if ($extraField->type=='textfield' || $extraField->type=='csv' || $extraField->type=='labels' || $extraField->type=='checkbox' ) $active=$value->value;
some another on line 222
case 'checkbox': $output=JHTML::_('select.checkboxGroup', $defaultValues, 'K2ExtraField_'.$extraField->id.'[]','', 'value', 'name', $active); break;
and added on line 291 to be searchable
else if ($row->type=='multipleSelect' || $extraField->type=='checkbox'){ foreach ($jsonObject as $option){ if (in_array($option->value,$currentValue)) $value.=$option->name.' '; } }
in the
in the administrator/component/com_k2/view/extrafiled/extrafield.php
i added on line 48
$typeOptions[] = JHTML::_('select.option', 'checkbox', JText::_('Checkbox list'));
and in the administrator/component/com_k2/view/extrafiled/tmpl/default.php
i added case 'checkbox': under case 'multipleSelect':
i hope ı can be helpfull it is my first post to help peope this is important for me. I try to make realestate site by using k2 so checkboxes so important for tihs like search module and plugin but the advanced search not enough to do this how can ı overcome this poblem. ı couldnt solve the search problem checkboxes if anyone do this i appraciate him/her. İn addiiton ı can choose which extrafields are shown in module but the system of plugin and module is the same how can ı seperate this. I want to show some extrafiled in module in the some where but ı dont want to show anotherwhere it must be choosable. Thank you for reading. I am waiting for helpfull replies.
Please Log in or Create an account to join the conversation.
- mach
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 3
13 years 10 months ago #97398
by mach
Replied by mach on topic checkbox in extrafield with searching problem :/
didnt anyone wrote something here yet :S ı tried to help and wanted some helps but it didnt work as ı see :/
Please Log in or Create an account to join the conversation.