2017-10-12 2 views
0

처음 올린 글. 사전에 도움을 주셔서 감사합니다. 정말 감사.WordPress 테마에서 검색/새로 고침 검색 양식 버튼

전 세계의 빌라를 검색하기 위해 WordPress 테마로 작업 중이며, 사용자 정의 필드 응용 프로그램으로 채워진 필드, 드롭 다운 및 확인란을 지우는 재설정 버튼을 추가하고 싶습니다. 정상적인 리셋 버튼은 작동하지 않으며 비행 중에 PHP를 직접 가르치기 때문에 나는 손실에 처해 있습니다. 다음은 페이지에 대한 링크이며 일부 코드는 붙여 넣어서 내가보고있는 것에 대한 아이디어를 얻습니다.

테마 작성자가 저를 불어 넣었으니 정말 감사드립니다. 그 요소가 존재하지 않는

<a href="javascript:document.getElementById('form_[form_key]').reset();" autocomplete="off">Reset Form</a> 

를를 수정해야하는 코드의 라인이있다

LINK

<?php 
 
\t global $realty_theme_option, $wp_query; 
 
?> 
 

 
<form class="property-search-form border-box" action="<?php if (tt_page_id_template_search()) { echo get_permalink(tt_page_id_template_search()); } ?>"> 
 

 
\t <div class="row"> 
 

 
\t \t <?php if (isset($realty_theme_option['property-search-results-page']) && empty($realty_theme_option['property-search-results-page'])) { ?> 
 
\t \t \t <div class="col-xs-12" style="margin-bottom: 1em"> 
 
\t \t \t \t <p class="alert alert-info"><?php esc_html_e('Please go to "Appearance > Theme Options > Pages" and set the page you want to use as your property search results.', 'realty'); ?></p> 
 
\t \t \t </div> 
 
\t \t <?php } ?> 
 

 
\t \t <?php 
 
\t \t \t // Form select classes 
 
\t \t \t $form_select_class = 'form-control'; 
 

 
\t \t \t if ($realty_theme_option['enable-rtl-support'] || is_rtl()) { 
 
\t \t \t \t $form_select_class .= ' chosen-select chosen-rtl'; 
 
\t \t \t } else { 
 
\t \t \t \t $form_select_class .= ' chosen-select'; 
 
\t \t \t } 
 

 
\t \t \t $acf_field_array = array(); 
 

 
\t \t \t if (isset($realty_theme_option['property-search-features']) && ! tt_is_array_empty($realty_theme_option['property-search-features'])) { 
 
\t \t  $property_search_features = $realty_theme_option['property-search-features']; 
 
\t \t \t } else { 
 
\t \t \t \t $property_search_features = null; 
 
\t \t \t } 
 

 
\t \t \t $raw_search_params = get_query_var('property_search_parameters'); 
 
\t \t \t if (! tt_is_array_empty($raw_search_params)) { 
 
\t \t \t \t $search_parameters = $raw_search_params; 
 
\t \t \t } else if (isset($realty_theme_option['property-search-parameter']) && ! empty($realty_theme_option['property-search-parameter'])) { 
 
\t \t \t \t $search_parameters = $realty_theme_option['property-search-parameter']; 
 
\t \t \t } else { 
 
\t \t \t \t $search_parameters = null; 
 
\t \t \t } 
 

 
\t \t \t $raw_search_fields = get_query_var('property_search_fields'); 
 
\t \t \t if (! tt_is_array_empty($raw_search_fields)) { 
 
\t \t \t \t $search_fields = $raw_search_fields; 
 
\t \t \t } else if (isset($realty_theme_option['property-search-parameter']) && ! empty($realty_theme_option['property-search-parameter'])) { 
 
\t \t \t \t $search_fields = $realty_theme_option['property-search-field']; 
 
\t \t \t } else { 
 
\t \t \t \t $search_fields = null; 
 
\t \t \t } 
 

 
\t \t \t $raw_search_labels = get_query_var('property_search_labels'); 
 
\t \t \t if (! tt_is_array_empty($raw_search_labels)) { 
 
\t \t \t \t $search_labels = $raw_search_labels; 
 
\t \t \t } else if (isset($realty_theme_option['property-search-label']) && ! empty($realty_theme_option['property-search-label'])) { 
 
\t \t \t \t $search_labels = $realty_theme_option['property-search-label']; 
 
\t \t \t } else { 
 
\t \t \t \t $search_labels = null; 
 
\t \t \t } 
 

 
\t \t \t $default_search_fields_array = array(
 
\t \t \t \t 'estate_search_by_keyword', 
 
\t \t \t \t 'estate_property_id', 
 
\t \t \t \t 'estate_property_location', 
 
\t \t \t \t 'estate_property_type', 
 
\t \t \t \t 'estate_property_status', 
 
\t \t \t \t 'estate_property_price', 
 
\t \t \t \t 'estate_property_price_min', 
 
\t \t \t \t 'estate_property_price_max', 
 
\t \t \t \t 'estate_property_pricerange', 
 
\t \t \t \t 'estate_property_size', 
 
\t \t \t \t 'estate_property_rooms', 
 
\t \t \t \t 'estate_property_bedrooms', 
 
\t \t \t \t 'estate_property_bathrooms', 
 
\t \t \t \t 'estate_property_garages', 
 
\t \t \t \t 'estate_property_available_from' 
 
\t \t \t); 
 

 
\t \t \t $i = 0; 
 

 
\t \t \t if (isset($search_form_columns) && ! empty($search_form_columns)) { 
 
\t \t \t \t // Use $columns parameter from shortcode [property_search_form] 
 
\t \t \t \t $count_search_fields = $search_form_columns; 
 
\t \t \t } else { 
 
\t \t \t \t // No shortcode $columns found, pick columns according to total field count 
 
\t \t \t \t $count_search_fields = count($search_fields); 
 
\t \t \t } 
 

 
\t \t \t if ($count_search_fields == 1) { 
 
\t \t \t \t $columns = 'col-xs-12'; 
 
\t \t \t } else if ($count_search_fields == 2) { 
 
\t \t \t \t $columns = 'col-xs-12 col-sm-6'; 
 
\t \t \t } else if ($count_search_fields == 3) { 
 
\t \t \t \t $columns = 'col-xs-12 col-sm-6 col-md-4'; 
 
\t \t \t } else { 
 
\t \t \t \t $columns = 'col-xs-12 col-sm-4 col-md-3'; 
 
\t \t \t } 
 

 
\t \t \t if (is_page_template('template-map-vertical.php')) { 
 
\t \t \t \t $columns = 'col-xs-12 col-sm-6'; 
 
\t \t \t } 
 

 
\t \t \t // Do we have any search parameters defined? 
 
\t \t \t if (isset($search_parameters) && ! empty($search_parameters[0])) { 
 

 
\t \t \t \t foreach ($search_fields as $search_field) { 
 

 
\t \t \t \t \t $search_parameter = $search_parameters[$i]; 
 

 
\t \t \t \t \t // Check If Search Field Is Filled Out 
 
\t \t \t \t \t if (! empty($search_field)) { 
 

 
\t \t \t \t \t \t // Default Property Field 
 
\t \t \t \t \t \t if (in_array($search_field, $default_search_fields_array)) { 
 

 
\t \t \t \t \t \t \t switch ($search_field) { 
 

 
\t \t \t \t \t \t \t \t case 'estate_search_by_keyword' : 
 
\t \t \t \t \t \t \t \t case 'estate_property_id' : 
 
\t \t \t \t \t \t \t \t ?> 
 
\t \t \t \t \t \t \t \t <div class="<?php echo $columns; ?> form-group"> 
 
\t \t \t \t \t \t \t \t \t <input type="text" name="<?php echo $search_parameter; ?>" id="<?php echo $search_parameter; ?>" value="<?php echo isset($_GET[$search_parameter]) ? $_GET[$search_parameter] : ''; ?>" placeholder="<?php echo $search_labels[$i]; ?>" class="form-control" /> 
 
\t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t \t <?php 
 
\t \t \t \t \t \t \t \t break; 
 

 
\t \t \t \t \t \t \t \t case 'estate_property_location' : ?> 
 
\t \t \t \t \t \t \t \t <div class="<?php echo $columns; ?> form-group select"> 
 
\t \t \t \t \t \t \t \t \t <?php 
 
\t \t \t \t \t \t \t \t \t \t // http://wordpress.stackexchange.com/questions/14652/how-to-show-a-hierarchical-terms-list#answer-14658 
 
\t \t \t \t \t \t \t \t \t \t if (! empty($search_labels[$i])) { 
 
\t \t \t \t \t \t \t \t \t \t \t $search_label_location = $search_labels[$i]; 
 
\t \t \t \t \t \t \t \t \t \t } else { 
 
\t \t \t \t \t \t \t \t \t \t \t $search_label_location = esc_html__('Any Location', 'realty'); 
 
\t \t \t \t \t \t \t \t \t \t } 
 
\t \t \t \t \t \t \t \t \t ?> 
 
\t \t \t \t \t \t \t \t \t <select name="<?php echo $search_parameter; ?>" id="<?php echo $search_parameter; ?>" class="<?php echo esc_attr($form_select_class); ?>"> 
 
\t \t \t \t \t \t \t \t \t \t <option value="all"><?php echo $search_label_location; ?></option> 
 
\t \t \t \t \t \t \t \t  <?php 
 
\t \t \t \t \t \t \t \t \t  $location = get_terms('property-location', array(
 
\t \t \t \t \t \t \t \t \t  \t 'orderby' => 'slug', 
 
\t \t \t \t \t \t \t \t \t  \t 'parent' => 0, 
 
\t \t \t \t \t \t \t \t \t  \t 'hide_empty' => false 
 
\t \t \t \t \t \t \t \t \t )); 
 

 
\t \t \t \t \t \t \t \t \t  if (isset($_GET[$search_parameter])) { 
 
\t \t \t \t \t \t \t \t \t \t \t \t $get_location = $_GET[$search_parameter]; 
 
\t \t \t \t \t \t \t \t \t \t \t } else { 
 
\t \t \t \t \t \t \t \t \t \t \t \t $get_location = null; 
 
\t \t \t \t \t \t \t \t \t \t \t } 
 
\t \t \t \t \t \t \t \t \t \t ?> 
 

 
\t \t \t \t \t \t \t \t  <?php foreach ($location as $key => $location) : ?> 
 
\t \t \t \t \t \t   <option value="<?php echo $location->slug; ?>" <?php selected($location->slug, $get_location); ?>> 
 
\t \t \t \t \t    <?php 
 
\t \t \t \t \t \t    echo $location->name; 
 

 
\t \t \t \t \t \t    $location2 = get_terms('property-location', array(
 
\t \t \t \t \t \t    \t 'orderby' => 'slug', 
 
\t \t \t \t \t \t    \t 'parent' => $location->term_id 
 
\t \t \t \t \t \t   )); 
 

 
\t \t \t \t \t \t    if ($location2) : 
 
\t \t \t \t \t    ?> 
 
\t \t \t \t \t    <optgroup> 
 
\t \t \t \t \t    <?php foreach($location2 as $key => $location2) : ?> 
 
\t \t \t \t \t     <option value="<?php echo $location2->slug; ?>" class="level2" <?php selected($location2->slug, $get_location); ?>> 
 
\t \t \t \t \t     \t <?php 
 
\t \t \t \t \t \t     \t echo $location2->name; 
 

 
\t \t \t \t \t \t     \t $location3 = get_terms('property-location', array(
 
\t \t \t \t \t \t     \t \t 'orderby' => 'slug', 
 
\t \t \t \t \t \t     \t \t 'parent' => $location2->term_id 
 
\t \t \t \t \t \t     \t)); 
 

 
\t \t \t \t \t \t     \t if ($location3) : 
 
\t \t \t \t \t     \t ?> 
 
\t \t \t \t \t     \t <optgroup> 
 
\t \t \t \t \t     \t \t <?php foreach($location3 as $key => $location3) : ?> 
 
\t \t \t \t \t      \t \t <option value="<?php echo $location3->slug; ?>" class="level3" <?php selected($location3->slug, $get_location); ?>> 
 
\t \t \t \t \t      \t \t <?php 
 
\t \t \t \t \t      \t \t echo $location3->name; 
 
\t \t \t \t \t \t      \t $location4 = get_terms('property-location', array('orderby' => 'slug', 'parent' => $location3->term_id)); 
 
\t \t \t \t \t \t      \t if($location4) : 
 
\t \t \t \t \t      \t \t ?> 
 
\t \t \t \t \t      \t \t <optgroup> 
 
\t \t \t \t \t      \t \t \t <?php foreach($location4 as $key => $location4) : ?> 
 
\t \t \t \t \t      \t \t \t <option value="<?php echo $location4->slug; ?>" class="level4" <?php selected($location4->slug, $get_location); ?>> 
 
\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t <?php echo $location4->name; ?> 
 
\t \t \t \t \t      \t \t \t </option> 
 
\t \t \t \t \t      \t \t \t <?php endforeach; ?> 
 
\t \t \t \t \t      \t \t </optgroup> 
 
\t \t \t \t \t      \t \t <?php endif; ?> 
 
\t \t \t \t \t      \t \t </option> 
 
\t \t \t \t \t     \t \t <?php endforeach; ?> 
 
\t \t \t \t \t     \t </optgroup> 
 
\t \t \t \t \t     \t <?php endif; ?> 
 
\t \t \t \t \t     </option> 
 
\t \t \t \t \t    <?php endforeach; ?> 
 
\t \t \t \t \t    </optgroup> 
 
\t \t \t \t \t    <?php endif; ?> 
 
\t \t \t \t \t \t   </option> 
 
\t \t \t \t \t \t \t \t  <?php endforeach; ?> 
 
\t \t \t \t \t \t \t \t \t </select> 
 
\t \t \t \t \t \t \t \t </div>

+0

처럼 뭔가 라인을 교체합니다. 모든 폼 값을 지우려면 리셋 버튼을 클릭 할 때 실행되는 jQuery 또는 javascript 코드를 작성해야합니다. –

답변

0

는, 형태는 사용할 수있는 property-search-form라는 클래스를 가지고 선택자로.

그래서 난 당신이 리셋 버튼을 누를 때 약간의 자바 스크립트 오류가 콘솔에 오는 것을 볼 수 있습니다

<a href="javascript:document.getElementsByClassName('property-search-form').reset();" autocomplete="off">Reset Form</a> 
+0

앤드류 감사합니다. 응답을 감사하십시오. 이제 자바 스크립트를 실행해야합니다. 나는이 주제를 많이 편집 한 적이 없다. – eyetrip

+0

수정 사항을 덮어 쓰게되므로 테마를 편집하는 것이 이상적이지 않습니다. –

관련 문제