Hi Frosticek,
About upgrading the city as text field instead of drop-down field, I found a good Osclass tutorial as below :https://doc.osclass.org/Changing_between_drop-down_and_autocomplete_for_locationsChanging between drop-down and autocomplete for locations :
Auto-complete input
Pros
More freedom is given to users, they will be able to select a location from the current database/list if they start typing it, but they will also be able to introduce new data.
Cons
They are allowed to enter anything as a location. You should trust your users.
How to enable it
To enable the auto-complete input, you need to modify two front-end files of your current theme, item-edit.php and item-post.php, also an admin file (oc-admin/themes/modern/items/frm.php).
First, change the JS call from (this change is common to all three files):
<?php ItemForm::location_javascript(); ?>
to
<?php ItemForm::location_javascript_new(); ?>
item-edit.php, from :
<?php ItemForm::region_select() ; ?>
...
<?php ItemForm::city_select() ; ?>
to:
<?php ItemForm::region_text() ; ?>
...
<?php ItemForm::city_text() ; ?>
item-post.php, from :
<?php ItemForm::region_select(osc_get_regions(osc_user_country_code()), osc_user()) ; ?>
...
<?php ItemForm::city_select(osc_get_cities(osc_user_region_id()), osc_user()) ; ?>
to:
<?php ItemForm::region_text(osc_user()) ; ?>
...
<?php ItemForm::city_text(osc_user()) ; ?>
frm.php, from :
<?php ItemForm::country_select($countries, $item) ; ?>
...
<?php ItemForm::region_select($regions, $item) ; ?>
...
<?php ItemForm::city_select($cities, $item) ; ?>
to:
<?php ItemForm::country_text($item) ; ?>
...
<?php ItemForm::region_text($item) ; ?>
...
<?php ItemForm::city_text($item) ; ?>
Then, I applied the previous procedure with a free Osclass theme and it works well ...
However, it doesn't work with Zara theme and I don't know anything about coding ...
Then I inhibit few lines of codes (ajax codes) in the Item-post file of Zara theme as below (I found a great tutorial from you to learn how to inhibit lines of codes) :1) oc-admin/themes/modern/users/frm.php
1.1) BEFORE :
}?>
<?php UserForm::location_javascript("admin"); ?>
1.2) AFTER :
}?>
<?php UserForm::location_javascript_new("admin"); ?>
1.3) BEFORE :
<div class="form-controls">
<?php UserForm::city_select($cities, $user); ?>
</div>
1.4) AFTER :
<div class="form-controls">
<?php UserForm::city_text($user); ?>
</div>
2) oc-content/themes/zara/item-post.php
2.1) REMOVE THE LINE No. 509 :
2.1.1) BEFORE :
$("#city").before('<select name="cityId" id="cityId"><option selected="selected" value=""><?php echo osc_esc_js(__('Select a city', 'zara')); ?></option></select>').remove();
2.1.1) AFTER :
// $("#city").before('<select name="cityId" id="cityId"><option selected="selected" value=""><?php echo osc_esc_js(__('Select a city', 'zara')); ?></option></select>').remove();
2.2) REMOVE THE LINE No. 512 :
2.2.1) BEFORE :
$("#cityId").val("").attr('disabled',true);
2.2.1) AFTER :
// $("#cityId").val("").attr('disabled',true);
2.3) REMOVE THE LINE No. 517 :
2.3.1) BEFORE :
$("#cityId").before('<input placeholder="<?php echo osc_esc_js(__('Enter a city', 'zara')); ?>" type="text" name="cityId" id="city" />').remove();;
2.3.1) AFTER :
// $("#cityId").before('<input placeholder="<?php echo osc_esc_js(__('Enter a city', 'zara')); ?>" type="text" name="cityId" id="city" />').remove();;
2.4) REMOVE THE LINE No. 520 :
2.4.1) BEFORE :
$("#city").val('').attr('disabled',true);
2.4.1) AFTER :
// $("#city").val('').attr('disabled',true);
2.5) REMOVE THE LINE No. 523, 524 :
2.5.1) BEFORE :
$("#cityId").html('<option selected="selected" value=""><?php echo osc_esc_js(__('Select a city', 'zara')); ?></option>');
}
2.5.1) AFTER :
// $("#cityId").html('<option selected="selected" value=""><?php echo osc_esc_js(__('Select a city', 'zara')); ?></option>');
// }
RESULT of the MODIFICATION : both Publish, Edit and Search of the CITY as text field instead of Drop-down work very well ...
Please is it OK was I did ?
I don't know coding at all, please what could be the best modification of codes ?The reason of these questions is that I bought many mb-themes plugins; I plan to buy few more and later on, and I am a bit worried about the consequence of such coding modification made without knowing anything about coding ...!!!
Thank you ,
Chris