Advertisement:

Author Topic: Changing between drop-down and autocomplete for locations, (SOLVED)  (Read 5162 times)

bazinga

  • Full Member
  • ***
  • Posts: 125
hello, Im using OSCLASS 3.3.2 THEME/MODERN,.

I want to Change to DROP-DOWN, Regions & Cities,. instead of autocomplete, (kuz it is SLOW to find the objetive city or Region).

I did exactly,. I THINKS So,. HOW IT SAYS here IN the OSCLASS /DOCS:

http://doc.osclass.org/Changing_between_drop-down_and_autocomplete_for_locations
Code: [Select]
How to enable it
To enable the drop-down menu, 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_new(); ?>
to

<?php ItemForm::location_javascript(); ?>

item-edit.php, from :

<?php ItemForm::region_text() ; ?>
...
<?php ItemForm::city_text() ; ?>
to:

<?php ItemForm::region_select() ; ?>
...
<?php ItemForm::city_select() ; ?>

item-post.php, from :

<?php ItemForm::region_text(osc_user()) ; ?>
...
<?php ItemForm::city_text(osc_user()) ; ?>
to:

<?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()) ; ?>

frm.php, from :

<?php ItemForm::country_text($item) ; ?>
...
<?php ItemForm::region_text($item) ; ?>
...
<?php ItemForm::city_text($item) ; ?>
to:

<?php ItemForm::country_select( ) ; ?>
...
<?php ItemForm::region_select( ) ; ?>
...
<?php ItemForm::city_select( ) ; ?>

BUT,. FOR ME,. IT DIDNT WORK,. IT MAKE A MESS,. IT WAS ALL BREAK., WHEN i tried to POST,..
Actually it didnt show,. anything of Regions and Cities...   :o ::) :o :-\

if there is A second option,. to do it Better,. or a way to BE MORE ESPECIFIC., what and where to make CHANGES,.
HEELP;: ME PLEASE..

thank you..!
« Last Edit: March 09, 2015, 08:43:57 am by bazinga »

mahesh

  • Full Member
  • ***
  • Posts: 116
Hi bazinga,

Place the following code in  oc-includes/osclass/helpers/hUsers.php

Code: [Select]
function osc_user_country_code() {
        return (string) osc_user_field("fk_c_country_code");
    }

Then it'll be worked. I tested in osclass 3.3.2 , modern theme it is working for me

bazinga

  • Full Member
  • ***
  • Posts: 125
@mahesh

you mean, I should just paste your code:
Code: [Select]
function osc_user_country_code() {
        return (string) osc_user_field("fk_c_country_code");
    }

and thats all.. Its DONE??

Or

After I make all the Changes what it says here:
http://doc.osclass.org/Changing_between_drop-down_and_autocomplete_for_locations

then I PASTE YOUR CODE,..?

help,. thank you..

byteGator

  • Osclass Hero
  • Sr. Member
  • *
  • Posts: 346
  • Simple Mind is a Beautiful Mind
@mahesh

you mean, I should just paste your code:
Code: [Select]
function osc_user_country_code() {
        return (string) osc_user_field("fk_c_country_code");
    }

and thats all.. Its DONE??

Or

After I make all the Changes what it says here:
http://doc.osclass.org/Changing_between_drop-down_and_autocomplete_for_locations

then I PASTE YOUR CODE,..?

help,. thank you..

@bazinga

http://forums.osclass.org/themes/trick-for-bender-theme-change-item-post-location-to-dropdown-selector/msg88739/#msg88739

mahesh

  • Full Member
  • ***
  • Posts: 116
After you  make all the Changes what it says here:
http://doc.osclass.org/Changing_between_drop-down_and_autocomplete_for_locations

and then add the code which i gave

bazinga

  • Full Member
  • ***
  • Posts: 125
hello @mahesh

I made all the changes,.. and I paste your Code,..
and now, it doesnt work,..  when you click on "Post Ad Free", it shows a white page,..  (http://www.domain.com/item/new ) nothing happend,..

I paste your code here,. hUsers.php
Code: [Select]

    /**
     * Gets phone_land if exist, else if exist return phone_mobile,
     * else return string blank
     * @return string
     */
    function osc_user_phone() {
        if(osc_user_field("s_phone_land")!="") {
            return osc_user_field("s_phone_land");
        } else if(osc_user_field("s_phone_mobile")!="") {
            return osc_user_field("s_phone_mobile");
        }
        return "";
    }

[color=red][b] function osc_user_country_code() {
        return (string) osc_user_field("fk_c_country_code");
    }[/b][/color]

    /**
     * Gets country of current user
     *
     * @return string
     */
    function osc_user_country() {
        return (string) osc_user_field("s_country");
    }

    /**
     * Gets region of current user
     *
     * @return string
     */
    function osc_user_region() {
        return (string) osc_user_field("s_region");
    }

   

do you have another option,..?
thank you...

blacklevel

  • Newbie
  • *
  • Posts: 2
I Have added this code to the hUsers.php, and just now all drop-downs works fine..
CODE:

Code: [Select]
function osc_user_country_code() {
        return (string) osc_user_field("fk_c_country_code");
    }
function osc_user_region_id() {
        return (string) osc_user_field("fk_c_region_id");
    }

bazinga

  • Full Member
  • ***
  • Posts: 125
thank you @blacklevel
I will repeat again the same process and Adding those codes,.. let see what happend,..! I hope it work for me,..
thank you for the advice..
I give you news soon... ::) ::) ::) ::)

bazinga

  • Full Member
  • ***
  • Posts: 125
no..
It didn't work for me,..

I have already drop down, Country,.. as default..

I want Just to Drop Down REGION, and CITY...

================
I have configurated "frm.php" with this code.
Code: [Select]
<?php ItemForm::location_javascript_new('admin'); ?>

my question is if I need to let it like that,.. with the word "admin",.or take it out..
and change it like this..

Code: [Select]
<?php ItemForm::location_javascript(); ?>


why this tutorial, seems very easy to do,.
http://doc.osclass.org/Changing_between_drop-down_and_autocomplete_for_locations
but for me it doesn't work..


bazinga

  • Full Member
  • ***
  • Posts: 125
@blacklevel

my menu for COUNTRY,. it is worknig fine,.. already drop down the list..

but what I want to drop down is REGION and CITY,..

why I need to paste your code:
Code: [Select]
function osc_user_country_code() {
        return (string) osc_user_field("fk_c_country_code");
    }
function osc_user_region_id() {
        return (string) osc_user_field("fk_c_region_id");
    }

if I dont need to do any change to COUNTRY,..

what about CITY..??

why,. doesnt work EASY,. as it explain on the TUTORIAL,. from Osclass..??

HELP,...

thank you,,

johannesstromberg

  • Newbie
  • *
  • Posts: 30
I have same problem region dropdown work after I ad this code:
function osc_user_country_code() {
        return (string) osc_user_field("fk_c_country_code");
    }

But the city dropdown don't load all city....

I have tested this code, but it don't work it only get a blank page:

Code: [Select]
function osc_user_country_code() {
        return (string) osc_user_field("fk_c_country_code");
    }

function osc_user_region_id() {
        return (string) osc_user_field("fk_c_region_id");
    }

I fixed it i have made wrong in a code... ;D
« Last Edit: December 22, 2014, 05:11:58 pm by johannesstromberg »

bazinga

  • Full Member
  • ***
  • Posts: 125
POR FIN, YA LO LOGRE..!! FUNCIONA GENIAL.. MUCHAS GRACIAS POR SU AYUDA,.
"CONSEGUIR QUE PAIS, REGION Y CIUDAD, SEAN SELECCIONADOS DE UNA LISTA" (DROP-DOWN)
AQUI LES DEJO, COMO QUEDARON LOS CODIGOS DE CADA ARCHIVO,. PARA QUE A LOS SIGUIENTES VISITANTES LES SEA DE UTILIDAD.

PRIMERO: deben seguir el tutorial aqui mencionado.
http://doc.osclass.org/Changing_between_drop-down_and_autocomplete_for_locations
ojo: revisar los espacios..

para los 3 archivos:
 item-edit.php ;  item-post.php, y en archivo admin file (oc-admin/themes/modern/items/frm.php).

Sustituir:
<?php ItemForm::location_javascript_new(); ?>
por esto:
<?php ItemForm::location_javascript(); ?>

SEGUNDO:
Sustituir en el siguiente archivo:
item-edit.php:

<?php ItemForm::region_text(); ?>
...
<?php ItemForm::city_text(); ?>
por esto:

<?php ItemForm::region_select(); ?>
...
<?php ItemForm::city_select(); ?>


TERCERO:
sustituir en el siguiente archivo las lineas:
item-post.php:

<?php ItemForm::region_text(osc_user()); ?>
...
<?php ItemForm::city_text(osc_user()); ?>
por esto:

<?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()); ?>


CUARTO PASO:
sustituir en el siguiente archivo:
frm.php :  (oc-admin/themes/modern/items/frm.php).


<?php ItemForm::country_text($item); ?>
...
<?php ItemForm::region_text($item); ?>
...
<?php ItemForm::city_text($item); ?>
por esto:

<?php ItemForm::country_select(); ?>
...
<?php ItemForm::region_select(); ?>
...
<?php ItemForm::city_select(); ?>


QUINTO PASO:
Revisen que las lineas del Archivo 'hUsers.php' esten correctas:
( oc-includes/osclass/helpers/hUsers.php )

busquen y revisen dentro del cogido que estas lineas esten asi:
Code: [Select]
  /**
     * Gets phone_land if exist, else if exist return phone_mobile,
     * else return string blank
     * @return string
     */
    function osc_user_phone() {
        if(osc_user_field("s_phone_land")!="") {
            return osc_user_field("s_phone_land");
        } else if(osc_user_field("s_phone_mobile")!="") {
            return osc_user_field("s_phone_mobile");
        }
        return "";
    }

    /**
     * Gets country of current user
     *
     * @return string
     */
    function osc_user_country() {
        return (string) osc_user_field("s_country");
    }

function osc_user_country_code() {
        return (string) osc_user_field("fk_c_country_code");
    }

    /**
     * Gets region of current user
     *
     * @return string
     */
    function osc_user_region() {
        return (string) osc_user_field("s_region");
    }

    /**
     * Gets region id of current user
     *
     * @return string
     */
    function osc_user_region_id() {
        return (string) osc_user_field("fk_i_region_id");
    }

    /**
     * Gets city of current user
     *
     * @return string
     */
    function osc_user_city() {
        return (string) osc_user_field("s_city");
    }

    /**
     * Gets city id of current user
     *
     * @return string
     */
    function osc_user_city_id() {
        return (string) osc_user_field("fk_i_city_id");
    }


LISTO..!!
SEXTO Y ULTIMO PASO:

ACTUALICEN LOS ARCHIVOS EN SU SERVIDOR..
SALUDOS.. ;)

aatishelp

  • Newbie
  • *
  • Posts: 5
Re: Changing between drop-down and autocomplete for locations, (SOLVED)
« Reply #12 on: June 30, 2018, 08:02:06 am »
you are not explaining good what about the first thing they said change the js class but where is js call is inside a file or what it is please explain good about the first step where we need to chhange the js call but from where from what file ?