*

Chris041973

  • ***
  • 58 posts
ZARA Theme : Country/Region drop-down is Great - No database for city !! Please how to change city as field text ?

I have upgraded the neighborhood countries & Region database as drop-down fields with the great help of Zara theme & Wikipedia …

However, I don’t have any database for cities because It could be 2 different translations for the city (“city/town”) according to the National or local languages/dialects.

I have bought the “Back-office” plugin from mb-themes which is a really great plugin and offers a lot of options, for instance setting up the location as required field during the registration & adding a Listing but doesn’t have the option to set up the city as text field …

Please I need your help to CODE THE CITY AS TEXT FIELD in the “Post Item”, “Edit Item” & “Search Item” pages … because I am blocked to launch my website without the city field …

Thank you in advance for your help.
« Last Edit: June 02, 2017, 03:45:18 PM by Chris041973 »

*

MB Themes

Re: No database for city !! Please how to CODE CITY AS TEXT FIELD ?
« Reply #1 on: June 04, 2017, 09:40:23 PM »
@Chris041973
In file:
/oc-content/themes/zara/item-post.php
/oc-content/themes/zara/item-edit.php

Find:
Code: [Select]
ItemForm::city_select
Change to:
Code: [Select]
ItemForm::city_text
You can find more modifications on osclass forums.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Chris041973

  • ***
  • 58 posts
Re: No database for city !! Please how to CODE CITY AS TEXT FIELD ?
« Reply #2 on: June 05, 2017, 08:16:03 AM »
Thank you ...
Please what about the search ?

*

MB Themes

Re: No database for city !! Please how to CODE CITY AS TEXT FIELD ?
« Reply #3 on: June 05, 2017, 08:51:18 AM »
@Chris
You need to modify file:
oc-content/themes/zara/search.php

There is generated select for city box, you need to modify this into text input, however I do not have code for that so it's on you.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Chris041973

  • ***
  • 58 posts
Re: No database for city !! Please how to CODE CITY AS TEXT FIELD ?
« Reply #4 on: June 07, 2017, 10:10:45 AM »
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_locations
Changing 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
« Last Edit: June 07, 2017, 10:22:51 AM by Chris041973 »